diff --git a/sale_exception_user/__init__.py b/sale_exception_user/__init__.py index 40272379..455a4c33 100644 --- a/sale_exception_user/__init__.py +++ b/sale_exception_user/__init__.py @@ -1 +1,3 @@ +# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. + from . import wizard diff --git a/sale_exception_user/__manifest__.py b/sale_exception_user/__manifest__.py index 4b987814..8cb213de 100644 --- a/sale_exception_user/__manifest__.py +++ b/sale_exception_user/__manifest__.py @@ -2,7 +2,7 @@ { 'name': 'Sale Exception Rule User', - 'version': '13.0.1.0.0', + 'version': '14.0.1.0.0', 'author': 'Hibou Corp.', 'license': 'OPL-1', 'category': 'Generic Modules', diff --git a/sale_exception_user/tests/__init__.py b/sale_exception_user/tests/__init__.py new file mode 100644 index 00000000..e236a89d --- /dev/null +++ b/sale_exception_user/tests/__init__.py @@ -0,0 +1,3 @@ +# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. + +from . import test_sale_exception_user diff --git a/sale_exception_user/tests/test_sale_exception_user.py b/sale_exception_user/tests/test_sale_exception_user.py new file mode 100644 index 00000000..0e1175a8 --- /dev/null +++ b/sale_exception_user/tests/test_sale_exception_user.py @@ -0,0 +1,59 @@ +# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. + +from odoo.tests import Form, SavepointCase + + +class TestSaleException(SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + groups = (cls.env.ref('base_exception_user.group_exception_rule_user') | + cls.env.ref('sales_team.group_sale_manager')) + user_dict = { + "name": "User test", + "login": "tua@example.com", + "password": "base-test-passwd", + "email": "armande.hruser@example.com", + "groups_id": [(6, 0, groups.ids)], + } + cls.user_test = cls.env['res.users'].create(user_dict) + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + + def test_sale_exception_user(self): + with self.with_user(self.user_test.login): + exception = self.env.ref("sale_exception.excep_no_zip").sudo() + exception.active = True + exception.allow_user_ignore = True + + partner = self.env.ref("base.res_partner_1") + partner.zip = False + p = self.env.ref("product.product_product_6") + so1 = self.env["sale.order"].create( + { + "partner_id": partner.id, + "partner_invoice_id": partner.id, + "partner_shipping_id": partner.id, + "order_line": [ + ( + 0, + 0, + { + "name": p.name, + "product_id": p.id, + "product_uom_qty": 2, + "product_uom": p.uom_id.id, + "price_unit": p.list_price, + }, + ) + ], + "pricelist_id": self.env.ref("product.list0").id, + } + ) + + action = so1.action_confirm() + wizard = Form(self.env[action['res_model']].with_user(self.user_test).with_context(action['context'])).save() + self.assertTrue(wizard.show_ignore_button) + action = wizard.action_ignore() + self.assertEqual(action.get('type'), 'ir.actions.act_window_close') + self.assertTrue(so1.ignore_exception) + self.assertEqual(so1.state, 'sale') diff --git a/sale_exception_user/wizard/__init__.py b/sale_exception_user/wizard/__init__.py index fcf2f6c2..5d468fa7 100644 --- a/sale_exception_user/wizard/__init__.py +++ b/sale_exception_user/wizard/__init__.py @@ -1 +1,3 @@ +# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. + from . import sale_exception_confirm diff --git a/sale_exception_user/wizard/sale_exception_confirm.py b/sale_exception_user/wizard/sale_exception_confirm.py index 9e52951e..b096f54b 100644 --- a/sale_exception_user/wizard/sale_exception_confirm.py +++ b/sale_exception_user/wizard/sale_exception_confirm.py @@ -1,3 +1,5 @@ +# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. + from odoo import fields, models