From d8da5f72dd80eed375547f500067939cb0c1a357 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 13 Aug 2013 21:00:02 +0200 Subject: [PATCH 01/57] [MRG] from master branch (../trunk-generic/ rev 29.1.1) --- sale_cancel_reason/__init__.py | 23 +++++++ sale_cancel_reason/__openerp__.py | 50 +++++++++++++++ .../data/sale_order_cancel_reason.xml | 14 ++++ sale_cancel_reason/model/__init__.py | 22 +++++++ sale_cancel_reason/model/sale.py | 44 +++++++++++++ .../security/ir.model.access.csv | 3 + sale_cancel_reason/test/sale_order_cancel.yml | 33 ++++++++++ sale_cancel_reason/view/sale_view.xml | 61 ++++++++++++++++++ sale_cancel_reason/wizard/__init__.py | 22 +++++++ sale_cancel_reason/wizard/cancel_reason.py | 64 +++++++++++++++++++ .../wizard/cancel_reason_view.xml | 39 +++++++++++ 11 files changed, 375 insertions(+) create mode 100644 sale_cancel_reason/__init__.py create mode 100644 sale_cancel_reason/__openerp__.py create mode 100644 sale_cancel_reason/data/sale_order_cancel_reason.xml create mode 100644 sale_cancel_reason/model/__init__.py create mode 100644 sale_cancel_reason/model/sale.py create mode 100644 sale_cancel_reason/security/ir.model.access.csv create mode 100644 sale_cancel_reason/test/sale_order_cancel.yml create mode 100644 sale_cancel_reason/view/sale_view.xml create mode 100644 sale_cancel_reason/wizard/__init__.py create mode 100644 sale_cancel_reason/wizard/cancel_reason.py create mode 100644 sale_cancel_reason/wizard/cancel_reason_view.xml diff --git a/sale_cancel_reason/__init__.py b/sale_cancel_reason/__init__.py new file mode 100644 index 00000000000..a75b125293b --- /dev/null +++ b/sale_cancel_reason/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Guewen Baconnier +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import wizard +from . import model diff --git a/sale_cancel_reason/__openerp__.py b/sale_cancel_reason/__openerp__.py new file mode 100644 index 00000000000..0189bd2afac --- /dev/null +++ b/sale_cancel_reason/__openerp__.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Guewen Baconnier +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{'name': 'Sale Cancel Reason', + 'version': '1.0', + 'author': 'Camptocamp', + 'category': 'Sale', + 'license': 'AGPL-3', + 'complexity': 'normal', + 'images': [], + 'website': "http://www.camptocamp.com", + 'description': """ +Sale Cancel Reason +================== + +When a sale order is canceled, a reason must be given, +it is choosed from a configured list. + +""", + 'depends': ['sale', + ], + 'demo': [], + 'data': ['wizard/cancel_reason_view.xml', + 'view/sale_view.xml', + 'security/ir.model.access.csv', + 'data/sale_order_cancel_reason.xml', + ], + 'auto_install': False, + 'test': ['test/sale_order_cancel.yml', + ], + 'installable': True, + } diff --git a/sale_cancel_reason/data/sale_order_cancel_reason.xml b/sale_cancel_reason/data/sale_order_cancel_reason.xml new file mode 100644 index 00000000000..c8eeb6f6b0f --- /dev/null +++ b/sale_cancel_reason/data/sale_order_cancel_reason.xml @@ -0,0 +1,14 @@ + + + + + Just for Quotation + + + No service needed anymore + + + Other Service Provider selected + + + diff --git a/sale_cancel_reason/model/__init__.py b/sale_cancel_reason/model/__init__.py new file mode 100644 index 00000000000..d65199e72a4 --- /dev/null +++ b/sale_cancel_reason/model/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Guewen Baconnier +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import sale diff --git a/sale_cancel_reason/model/sale.py b/sale_cancel_reason/model/sale.py new file mode 100644 index 00000000000..c5b9b01eb96 --- /dev/null +++ b/sale_cancel_reason/model/sale.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Guewen Baconnier +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm, fields +from openerp.tools.translate import _ + + +class sale_order(orm.Model): + _inherit = 'sale.order' + + _columns = { + 'cancel_reason_id': fields.many2one( + 'sale.order.cancel.reason', + string="Reason for cancellation", + readonly=True, + ondelete="restrict" + ), + } + + +class sale_order_cancel_reason(orm.Model): + _name = 'sale.order.cancel.reason' + _description = 'Sale Order Cancel Reason' + _columns = { + 'name': fields.char('Reason', required=True, translate=True), + } diff --git a/sale_cancel_reason/security/ir.model.access.csv b/sale_cancel_reason/security/ir.model.access.csv new file mode 100644 index 00000000000..032043ac33a --- /dev/null +++ b/sale_cancel_reason/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_sale_order_cancel_reason_user,access_sale_order_cancel_reason user,model_sale_order_cancel_reason,base.group_sale_salesman,1,0,0,0 +access_sale_order_cancel_reason_manager,access_sale_order_cancel_reason manager,model_sale_order_cancel_reason,base.group_sale_manager,1,1,1,1 diff --git a/sale_cancel_reason/test/sale_order_cancel.yml b/sale_cancel_reason/test/sale_order_cancel.yml new file mode 100644 index 00000000000..bd84000755e --- /dev/null +++ b/sale_cancel_reason/test/sale_order_cancel.yml @@ -0,0 +1,33 @@ +- + In order to test the choice of a cancel reason when canceling a sale order + I create a new cancel reason +- + !record {model: sale.order.cancel.reason, id: cancel_reason_test}: + name: Canceled for tests +- + Given I create a sale order +- + !record {model: sale.order, id: sale_order_cancel_01}: + partner_id: base.res_partner_2 + order_line: + - product_id: product.product_product_7 + product_uom_qty: 8 +- + When I cancel it with the wizard asking for the reason +- + !python {model: sale.order.cancel}: | + context = {'active_model': 'sale.order', + 'active_ids': [ref('sale_order_cancel_01')], + } + reason_id = ref('cancel_reason_test') + wizard_id = self.create(cr, uid, + {'reason_id': reason_id}, + context=context) + self.confirm_cancel(cr, uid, wizard_id, context=context) +- + Then the sale order should be canceled + and the reason stored +- + !assert {model: sale.order, id: sale_order_cancel_01, string: the sale order should be canceled}: + - state == 'cancel' + - cancel_reason_id.id == ref('cancel_reason_test') diff --git a/sale_cancel_reason/view/sale_view.xml b/sale_cancel_reason/view/sale_view.xml new file mode 100644 index 00000000000..664477999a8 --- /dev/null +++ b/sale_cancel_reason/view/sale_view.xml @@ -0,0 +1,61 @@ + + + + + sale.order.form + sale.order + + + + action + %(action_sale_order_cancel)d + + + action + %(action_sale_order_cancel)d + + +

+

+
+
+
+ + + Sale Order Cancel Reason + sale.order.cancel.reason + +
+ + +
+
+ + + Sale Order Cancel Reason + sale.order.cancel.reason + + + + + + + + + Sale Order Cancel Reason + sale.order.cancel.reason + form + tree,form + + + +
+
diff --git a/sale_cancel_reason/wizard/__init__.py b/sale_cancel_reason/wizard/__init__.py new file mode 100644 index 00000000000..5d55d1468a2 --- /dev/null +++ b/sale_cancel_reason/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Guewen Baconnier +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import cancel_reason diff --git a/sale_cancel_reason/wizard/cancel_reason.py b/sale_cancel_reason/wizard/cancel_reason.py new file mode 100644 index 00000000000..37a5c7685f0 --- /dev/null +++ b/sale_cancel_reason/wizard/cancel_reason.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Guewen Baconnier +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm, fields +from openerp import netsvc + + +class logistic_requisition_cancel(orm.TransientModel): + """ Ask a reason for the sale order cancellation.""" + _name = 'sale.order.cancel' + _description = __doc__ + + quotation_states = ['draft', 'sent'] + + _columns = { + 'reason_id': fields.many2one('sale.order.cancel.reason', + string='Reason', + required=True), + } + + def confirm_cancel(self, cr, uid, ids, context=None): + if context is None: + context = {} + if isinstance(ids, (list, tuple)): + assert len(ids) == 1, "1 ID expected" + ids = ids[0] + act_close = {'type': 'ir.actions.act_window_close'} + sale_ids = context.get('active_ids') + if sale_ids is None: + return act_close + assert len(sale_ids) == 1, "Only 1 sale ID expected" + form = self.browse(cr, uid, ids, context=context) + sale_obj = self.pool.get('sale.order') + sale_obj.write(cr, uid, sale_ids, + {'cancel_reason_id': form.reason_id.id}, + context=context) + sale = sale_obj.browse(cr, uid, sale_ids[0], context=context) + # in the official addons, they call the signal on quotations + # but directly call action_cancel on sales orders + if sale.state in self.quotation_states: + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'sale.order', + sale_ids[0], 'cancel', cr) + else: + sale_obj.action_cancel(cr, uid, sale_ids, context=context) + return act_close diff --git a/sale_cancel_reason/wizard/cancel_reason_view.xml b/sale_cancel_reason/wizard/cancel_reason_view.xml new file mode 100644 index 00000000000..2b1d56cbb4e --- /dev/null +++ b/sale_cancel_reason/wizard/cancel_reason_view.xml @@ -0,0 +1,39 @@ + + + + + Reason for the cancellation + sale.order.cancel + +
+

+ Choose the reason for the cancellation of the + sale order. +

+ + + +
+
+
+
+
+ + + Reason for the cancellation + ir.actions.act_window + sale.order.cancel + form + form + + new + +
+
+ From 6117b5a0416a5300200ea000fa665081745b8378 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Aug 2013 12:16:27 +0200 Subject: [PATCH 02/57] [FIX] sale cancel reason dependence (../trunk-generic/ rev 32.1.1) --- sale_cancel_reason/__openerp__.py | 2 +- sale_cancel_reason/view/sale_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sale_cancel_reason/__openerp__.py b/sale_cancel_reason/__openerp__.py index 0189bd2afac..bd94a24a678 100644 --- a/sale_cancel_reason/__openerp__.py +++ b/sale_cancel_reason/__openerp__.py @@ -36,7 +36,7 @@ """, 'depends': ['sale', - ], + 'sale_stock'], 'demo': [], 'data': ['wizard/cancel_reason_view.xml', 'view/sale_view.xml', diff --git a/sale_cancel_reason/view/sale_view.xml b/sale_cancel_reason/view/sale_view.xml index 664477999a8..e825f8f8fd1 100644 --- a/sale_cancel_reason/view/sale_view.xml +++ b/sale_cancel_reason/view/sale_view.xml @@ -4,7 +4,7 @@ sale.order.form sale.order - + action From d8520bc3701adc9d0da9539fbe2ecf157741ae68 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 9 Aug 2013 15:21:36 +0200 Subject: [PATCH 03/57] [FIX] sale_cancel_reason: remove dependency on sale_stock (../trunk-generic/ rev 32.1.2) --- sale_cancel_reason/__openerp__.py | 2 +- sale_cancel_reason/view/sale_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sale_cancel_reason/__openerp__.py b/sale_cancel_reason/__openerp__.py index bd94a24a678..0189bd2afac 100644 --- a/sale_cancel_reason/__openerp__.py +++ b/sale_cancel_reason/__openerp__.py @@ -36,7 +36,7 @@ """, 'depends': ['sale', - 'sale_stock'], + ], 'demo': [], 'data': ['wizard/cancel_reason_view.xml', 'view/sale_view.xml', diff --git a/sale_cancel_reason/view/sale_view.xml b/sale_cancel_reason/view/sale_view.xml index e825f8f8fd1..664477999a8 100644 --- a/sale_cancel_reason/view/sale_view.xml +++ b/sale_cancel_reason/view/sale_view.xml @@ -4,7 +4,7 @@ sale.order.form sale.order - + action From 6f7b40896eb46919b40825ea0b84b3bb7ced9538 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 29 Nov 2013 15:53:05 +0100 Subject: [PATCH 04/57] spellcheck --- sale_cancel_reason/__openerp__.py | 2 +- sale_cancel_reason/data/sale_order_cancel_reason.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sale_cancel_reason/__openerp__.py b/sale_cancel_reason/__openerp__.py index 0189bd2afac..af2dd13febc 100644 --- a/sale_cancel_reason/__openerp__.py +++ b/sale_cancel_reason/__openerp__.py @@ -32,7 +32,7 @@ ================== When a sale order is canceled, a reason must be given, -it is choosed from a configured list. +it is chosen from a configured list. """, 'depends': ['sale', diff --git a/sale_cancel_reason/data/sale_order_cancel_reason.xml b/sale_cancel_reason/data/sale_order_cancel_reason.xml index c8eeb6f6b0f..d827099e79d 100644 --- a/sale_cancel_reason/data/sale_order_cancel_reason.xml +++ b/sale_cancel_reason/data/sale_order_cancel_reason.xml @@ -5,7 +5,7 @@ Just for Quotation - No service needed anymore + Service no longer needed Other Service Provider selected From b7af6a97b807a76d06d48e6048cff6fa1d501dad Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 7 Aug 2014 12:23:36 +0200 Subject: [PATCH 05/57] [FIX] repository PEP8 --- sale_cancel_reason/__init__.py | 4 ++-- sale_cancel_reason/__openerp__.py | 4 ++-- sale_cancel_reason/model/__init__.py | 4 ++-- sale_cancel_reason/model/sale.py | 4 ++-- sale_cancel_reason/wizard/__init__.py | 4 ++-- sale_cancel_reason/wizard/cancel_reason.py | 5 +++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/sale_cancel_reason/__init__.py b/sale_cancel_reason/__init__.py index a75b125293b..fc574f3cfee 100644 --- a/sale_cancel_reason/__init__.py +++ b/sale_cancel_reason/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import wizard from . import model diff --git a/sale_cancel_reason/__openerp__.py b/sale_cancel_reason/__openerp__.py index af2dd13febc..ac8cdb0345f 100644 --- a/sale_cancel_reason/__openerp__.py +++ b/sale_cancel_reason/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# {'name': 'Sale Cancel Reason', 'version': '1.0', diff --git a/sale_cancel_reason/model/__init__.py b/sale_cancel_reason/model/__init__.py index d65199e72a4..d5d7f376f0f 100644 --- a/sale_cancel_reason/model/__init__.py +++ b/sale_cancel_reason/model/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import sale diff --git a/sale_cancel_reason/model/sale.py b/sale_cancel_reason/model/sale.py index c5b9b01eb96..93e28793bf5 100644 --- a/sale_cancel_reason/model/sale.py +++ b/sale_cancel_reason/model/sale.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm, fields from openerp.tools.translate import _ diff --git a/sale_cancel_reason/wizard/__init__.py b/sale_cancel_reason/wizard/__init__.py index 5d55d1468a2..37c6d2c3f63 100644 --- a/sale_cancel_reason/wizard/__init__.py +++ b/sale_cancel_reason/wizard/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import cancel_reason diff --git a/sale_cancel_reason/wizard/cancel_reason.py b/sale_cancel_reason/wizard/cancel_reason.py index 37a5c7685f0..98800af30fa 100644 --- a/sale_cancel_reason/wizard/cancel_reason.py +++ b/sale_cancel_reason/wizard/cancel_reason.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,13 +17,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm, fields from openerp import netsvc class logistic_requisition_cancel(orm.TransientModel): + """ Ask a reason for the sale order cancellation.""" _name = 'sale.order.cancel' _description = __doc__ From 442b219832f0d65e5960d91031deb816cc90d042 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 7 Aug 2014 15:19:35 +0200 Subject: [PATCH 06/57] [FIX] Still some PEP8 erros --- sale_cancel_reason/model/sale.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sale_cancel_reason/model/sale.py b/sale_cancel_reason/model/sale.py index 93e28793bf5..09ac3a7d264 100644 --- a/sale_cancel_reason/model/sale.py +++ b/sale_cancel_reason/model/sale.py @@ -20,7 +20,6 @@ # from openerp.osv import orm, fields -from openerp.tools.translate import _ class sale_order(orm.Model): From 2c50529a54f7a720b71a8bbfc7611535a33a30c7 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Fri, 8 Aug 2014 01:58:03 +0200 Subject: [PATCH 07/57] - Set as uninstallable and moved to __unported__ dir all modules. - Update travis.yml to 8.0 --- sale_cancel_reason/__init__.py | 23 ------- sale_cancel_reason/__openerp__.py | 50 -------------- .../data/sale_order_cancel_reason.xml | 14 ---- sale_cancel_reason/model/__init__.py | 22 ------- sale_cancel_reason/model/sale.py | 43 ------------ .../security/ir.model.access.csv | 3 - sale_cancel_reason/test/sale_order_cancel.yml | 33 ---------- sale_cancel_reason/view/sale_view.xml | 61 ----------------- sale_cancel_reason/wizard/__init__.py | 22 ------- sale_cancel_reason/wizard/cancel_reason.py | 65 ------------------- .../wizard/cancel_reason_view.xml | 39 ----------- 11 files changed, 375 deletions(-) delete mode 100644 sale_cancel_reason/__init__.py delete mode 100644 sale_cancel_reason/__openerp__.py delete mode 100644 sale_cancel_reason/data/sale_order_cancel_reason.xml delete mode 100644 sale_cancel_reason/model/__init__.py delete mode 100644 sale_cancel_reason/model/sale.py delete mode 100644 sale_cancel_reason/security/ir.model.access.csv delete mode 100644 sale_cancel_reason/test/sale_order_cancel.yml delete mode 100644 sale_cancel_reason/view/sale_view.xml delete mode 100644 sale_cancel_reason/wizard/__init__.py delete mode 100644 sale_cancel_reason/wizard/cancel_reason.py delete mode 100644 sale_cancel_reason/wizard/cancel_reason_view.xml diff --git a/sale_cancel_reason/__init__.py b/sale_cancel_reason/__init__.py deleted file mode 100644 index fc574f3cfee..00000000000 --- a/sale_cancel_reason/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- -# -# -# Author: Guewen Baconnier -# Copyright 2013 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# - -from . import wizard -from . import model diff --git a/sale_cancel_reason/__openerp__.py b/sale_cancel_reason/__openerp__.py deleted file mode 100644 index ac8cdb0345f..00000000000 --- a/sale_cancel_reason/__openerp__.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# -# -# Author: Guewen Baconnier -# Copyright 2013 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# - -{'name': 'Sale Cancel Reason', - 'version': '1.0', - 'author': 'Camptocamp', - 'category': 'Sale', - 'license': 'AGPL-3', - 'complexity': 'normal', - 'images': [], - 'website': "http://www.camptocamp.com", - 'description': """ -Sale Cancel Reason -================== - -When a sale order is canceled, a reason must be given, -it is chosen from a configured list. - -""", - 'depends': ['sale', - ], - 'demo': [], - 'data': ['wizard/cancel_reason_view.xml', - 'view/sale_view.xml', - 'security/ir.model.access.csv', - 'data/sale_order_cancel_reason.xml', - ], - 'auto_install': False, - 'test': ['test/sale_order_cancel.yml', - ], - 'installable': True, - } diff --git a/sale_cancel_reason/data/sale_order_cancel_reason.xml b/sale_cancel_reason/data/sale_order_cancel_reason.xml deleted file mode 100644 index d827099e79d..00000000000 --- a/sale_cancel_reason/data/sale_order_cancel_reason.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - Just for Quotation - - - Service no longer needed - - - Other Service Provider selected - - - diff --git a/sale_cancel_reason/model/__init__.py b/sale_cancel_reason/model/__init__.py deleted file mode 100644 index d5d7f376f0f..00000000000 --- a/sale_cancel_reason/model/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# -# -# Author: Guewen Baconnier -# Copyright 2013 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# - -from . import sale diff --git a/sale_cancel_reason/model/sale.py b/sale_cancel_reason/model/sale.py deleted file mode 100644 index 09ac3a7d264..00000000000 --- a/sale_cancel_reason/model/sale.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- -# -# -# Author: Guewen Baconnier -# Copyright 2013 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# - -from openerp.osv import orm, fields - - -class sale_order(orm.Model): - _inherit = 'sale.order' - - _columns = { - 'cancel_reason_id': fields.many2one( - 'sale.order.cancel.reason', - string="Reason for cancellation", - readonly=True, - ondelete="restrict" - ), - } - - -class sale_order_cancel_reason(orm.Model): - _name = 'sale.order.cancel.reason' - _description = 'Sale Order Cancel Reason' - _columns = { - 'name': fields.char('Reason', required=True, translate=True), - } diff --git a/sale_cancel_reason/security/ir.model.access.csv b/sale_cancel_reason/security/ir.model.access.csv deleted file mode 100644 index 032043ac33a..00000000000 --- a/sale_cancel_reason/security/ir.model.access.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_sale_order_cancel_reason_user,access_sale_order_cancel_reason user,model_sale_order_cancel_reason,base.group_sale_salesman,1,0,0,0 -access_sale_order_cancel_reason_manager,access_sale_order_cancel_reason manager,model_sale_order_cancel_reason,base.group_sale_manager,1,1,1,1 diff --git a/sale_cancel_reason/test/sale_order_cancel.yml b/sale_cancel_reason/test/sale_order_cancel.yml deleted file mode 100644 index bd84000755e..00000000000 --- a/sale_cancel_reason/test/sale_order_cancel.yml +++ /dev/null @@ -1,33 +0,0 @@ -- - In order to test the choice of a cancel reason when canceling a sale order - I create a new cancel reason -- - !record {model: sale.order.cancel.reason, id: cancel_reason_test}: - name: Canceled for tests -- - Given I create a sale order -- - !record {model: sale.order, id: sale_order_cancel_01}: - partner_id: base.res_partner_2 - order_line: - - product_id: product.product_product_7 - product_uom_qty: 8 -- - When I cancel it with the wizard asking for the reason -- - !python {model: sale.order.cancel}: | - context = {'active_model': 'sale.order', - 'active_ids': [ref('sale_order_cancel_01')], - } - reason_id = ref('cancel_reason_test') - wizard_id = self.create(cr, uid, - {'reason_id': reason_id}, - context=context) - self.confirm_cancel(cr, uid, wizard_id, context=context) -- - Then the sale order should be canceled - and the reason stored -- - !assert {model: sale.order, id: sale_order_cancel_01, string: the sale order should be canceled}: - - state == 'cancel' - - cancel_reason_id.id == ref('cancel_reason_test') diff --git a/sale_cancel_reason/view/sale_view.xml b/sale_cancel_reason/view/sale_view.xml deleted file mode 100644 index 664477999a8..00000000000 --- a/sale_cancel_reason/view/sale_view.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - sale.order.form - sale.order - - - - action - %(action_sale_order_cancel)d - - - action - %(action_sale_order_cancel)d - - -

-

-
-
-
- - - Sale Order Cancel Reason - sale.order.cancel.reason - -
- - -
-
- - - Sale Order Cancel Reason - sale.order.cancel.reason - - - - - - - - - Sale Order Cancel Reason - sale.order.cancel.reason - form - tree,form - - - -
-
diff --git a/sale_cancel_reason/wizard/__init__.py b/sale_cancel_reason/wizard/__init__.py deleted file mode 100644 index 37c6d2c3f63..00000000000 --- a/sale_cancel_reason/wizard/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# -# -# Author: Guewen Baconnier -# Copyright 2013 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# - -from . import cancel_reason diff --git a/sale_cancel_reason/wizard/cancel_reason.py b/sale_cancel_reason/wizard/cancel_reason.py deleted file mode 100644 index 98800af30fa..00000000000 --- a/sale_cancel_reason/wizard/cancel_reason.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- -# -# -# Author: Guewen Baconnier -# Copyright 2013 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# - -from openerp.osv import orm, fields -from openerp import netsvc - - -class logistic_requisition_cancel(orm.TransientModel): - - """ Ask a reason for the sale order cancellation.""" - _name = 'sale.order.cancel' - _description = __doc__ - - quotation_states = ['draft', 'sent'] - - _columns = { - 'reason_id': fields.many2one('sale.order.cancel.reason', - string='Reason', - required=True), - } - - def confirm_cancel(self, cr, uid, ids, context=None): - if context is None: - context = {} - if isinstance(ids, (list, tuple)): - assert len(ids) == 1, "1 ID expected" - ids = ids[0] - act_close = {'type': 'ir.actions.act_window_close'} - sale_ids = context.get('active_ids') - if sale_ids is None: - return act_close - assert len(sale_ids) == 1, "Only 1 sale ID expected" - form = self.browse(cr, uid, ids, context=context) - sale_obj = self.pool.get('sale.order') - sale_obj.write(cr, uid, sale_ids, - {'cancel_reason_id': form.reason_id.id}, - context=context) - sale = sale_obj.browse(cr, uid, sale_ids[0], context=context) - # in the official addons, they call the signal on quotations - # but directly call action_cancel on sales orders - if sale.state in self.quotation_states: - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'sale.order', - sale_ids[0], 'cancel', cr) - else: - sale_obj.action_cancel(cr, uid, sale_ids, context=context) - return act_close diff --git a/sale_cancel_reason/wizard/cancel_reason_view.xml b/sale_cancel_reason/wizard/cancel_reason_view.xml deleted file mode 100644 index 2b1d56cbb4e..00000000000 --- a/sale_cancel_reason/wizard/cancel_reason_view.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - Reason for the cancellation - sale.order.cancel - -
-

- Choose the reason for the cancellation of the - sale order. -

- - - -
-
-
-
-
- - - Reason for the cancellation - ir.actions.act_window - sale.order.cancel - form - form - - new - -
-
- From 510022058c907eb2d1f0882b3fbc6203174a0811 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Mon, 25 Aug 2014 14:55:38 +0200 Subject: [PATCH 08/57] reactivate sale_cancel_reason --- sale_cancel_reason/__init__.py | 23 +++++++ sale_cancel_reason/__openerp__.py | 50 ++++++++++++++ .../data/sale_order_cancel_reason.xml | 14 ++++ sale_cancel_reason/model/__init__.py | 22 +++++++ sale_cancel_reason/model/sale.py | 43 ++++++++++++ .../security/ir.model.access.csv | 3 + sale_cancel_reason/test/sale_order_cancel.yml | 33 ++++++++++ sale_cancel_reason/view/sale_view.xml | 63 ++++++++++++++++++ sale_cancel_reason/wizard/__init__.py | 22 +++++++ sale_cancel_reason/wizard/cancel_reason.py | 65 +++++++++++++++++++ .../wizard/cancel_reason_view.xml | 39 +++++++++++ 11 files changed, 377 insertions(+) create mode 100644 sale_cancel_reason/__init__.py create mode 100644 sale_cancel_reason/__openerp__.py create mode 100644 sale_cancel_reason/data/sale_order_cancel_reason.xml create mode 100644 sale_cancel_reason/model/__init__.py create mode 100644 sale_cancel_reason/model/sale.py create mode 100644 sale_cancel_reason/security/ir.model.access.csv create mode 100644 sale_cancel_reason/test/sale_order_cancel.yml create mode 100644 sale_cancel_reason/view/sale_view.xml create mode 100644 sale_cancel_reason/wizard/__init__.py create mode 100644 sale_cancel_reason/wizard/cancel_reason.py create mode 100644 sale_cancel_reason/wizard/cancel_reason_view.xml diff --git a/sale_cancel_reason/__init__.py b/sale_cancel_reason/__init__.py new file mode 100644 index 00000000000..fc574f3cfee --- /dev/null +++ b/sale_cancel_reason/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# +# +# Author: Guewen Baconnier +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# + +from . import wizard +from . import model diff --git a/sale_cancel_reason/__openerp__.py b/sale_cancel_reason/__openerp__.py new file mode 100644 index 00000000000..ac8cdb0345f --- /dev/null +++ b/sale_cancel_reason/__openerp__.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# +# +# Author: Guewen Baconnier +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# + +{'name': 'Sale Cancel Reason', + 'version': '1.0', + 'author': 'Camptocamp', + 'category': 'Sale', + 'license': 'AGPL-3', + 'complexity': 'normal', + 'images': [], + 'website': "http://www.camptocamp.com", + 'description': """ +Sale Cancel Reason +================== + +When a sale order is canceled, a reason must be given, +it is chosen from a configured list. + +""", + 'depends': ['sale', + ], + 'demo': [], + 'data': ['wizard/cancel_reason_view.xml', + 'view/sale_view.xml', + 'security/ir.model.access.csv', + 'data/sale_order_cancel_reason.xml', + ], + 'auto_install': False, + 'test': ['test/sale_order_cancel.yml', + ], + 'installable': True, + } diff --git a/sale_cancel_reason/data/sale_order_cancel_reason.xml b/sale_cancel_reason/data/sale_order_cancel_reason.xml new file mode 100644 index 00000000000..d827099e79d --- /dev/null +++ b/sale_cancel_reason/data/sale_order_cancel_reason.xml @@ -0,0 +1,14 @@ + + + + + Just for Quotation + + + Service no longer needed + + + Other Service Provider selected + + + diff --git a/sale_cancel_reason/model/__init__.py b/sale_cancel_reason/model/__init__.py new file mode 100644 index 00000000000..d5d7f376f0f --- /dev/null +++ b/sale_cancel_reason/model/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# +# +# Author: Guewen Baconnier +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# + +from . import sale diff --git a/sale_cancel_reason/model/sale.py b/sale_cancel_reason/model/sale.py new file mode 100644 index 00000000000..09ac3a7d264 --- /dev/null +++ b/sale_cancel_reason/model/sale.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# +# +# Author: Guewen Baconnier +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# + +from openerp.osv import orm, fields + + +class sale_order(orm.Model): + _inherit = 'sale.order' + + _columns = { + 'cancel_reason_id': fields.many2one( + 'sale.order.cancel.reason', + string="Reason for cancellation", + readonly=True, + ondelete="restrict" + ), + } + + +class sale_order_cancel_reason(orm.Model): + _name = 'sale.order.cancel.reason' + _description = 'Sale Order Cancel Reason' + _columns = { + 'name': fields.char('Reason', required=True, translate=True), + } diff --git a/sale_cancel_reason/security/ir.model.access.csv b/sale_cancel_reason/security/ir.model.access.csv new file mode 100644 index 00000000000..032043ac33a --- /dev/null +++ b/sale_cancel_reason/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_sale_order_cancel_reason_user,access_sale_order_cancel_reason user,model_sale_order_cancel_reason,base.group_sale_salesman,1,0,0,0 +access_sale_order_cancel_reason_manager,access_sale_order_cancel_reason manager,model_sale_order_cancel_reason,base.group_sale_manager,1,1,1,1 diff --git a/sale_cancel_reason/test/sale_order_cancel.yml b/sale_cancel_reason/test/sale_order_cancel.yml new file mode 100644 index 00000000000..bd84000755e --- /dev/null +++ b/sale_cancel_reason/test/sale_order_cancel.yml @@ -0,0 +1,33 @@ +- + In order to test the choice of a cancel reason when canceling a sale order + I create a new cancel reason +- + !record {model: sale.order.cancel.reason, id: cancel_reason_test}: + name: Canceled for tests +- + Given I create a sale order +- + !record {model: sale.order, id: sale_order_cancel_01}: + partner_id: base.res_partner_2 + order_line: + - product_id: product.product_product_7 + product_uom_qty: 8 +- + When I cancel it with the wizard asking for the reason +- + !python {model: sale.order.cancel}: | + context = {'active_model': 'sale.order', + 'active_ids': [ref('sale_order_cancel_01')], + } + reason_id = ref('cancel_reason_test') + wizard_id = self.create(cr, uid, + {'reason_id': reason_id}, + context=context) + self.confirm_cancel(cr, uid, wizard_id, context=context) +- + Then the sale order should be canceled + and the reason stored +- + !assert {model: sale.order, id: sale_order_cancel_01, string: the sale order should be canceled}: + - state == 'cancel' + - cancel_reason_id.id == ref('cancel_reason_test') diff --git a/sale_cancel_reason/view/sale_view.xml b/sale_cancel_reason/view/sale_view.xml new file mode 100644 index 00000000000..366f6284cc5 --- /dev/null +++ b/sale_cancel_reason/view/sale_view.xml @@ -0,0 +1,63 @@ + + + + + sale.order.form + sale.order + + + + True + + +