diff --git a/sale_stock_picking_blocking/models/sale_order.py b/sale_stock_picking_blocking/models/sale_order.py index 041b65f5a54..e5645f6b83a 100644 --- a/sale_stock_picking_blocking/models/sale_order.py +++ b/sale_stock_picking_blocking/models/sale_order.py @@ -19,12 +19,12 @@ class SaleOrder(models.Model): @api.constrains("delivery_block_id") def _check_not_auto_done(self): - auto_done = self.user_has_groups("sale.group_auto_done_setting") + auto_done = self.env.user.has_group("sale.group_auto_done_setting") if auto_done and any(so.delivery_block_id for so in self): raise ValidationError( - _('You cannot block a sale order with "auto_done_setting" ' "active.") + _('You cannot block a sale order with "auto_done_setting" active.') ) - + @api.depends("partner_id", "payment_term_id") def _compute_delivery_block_id(self): """Add the 'Default Delivery Block Reason' if set in the partner diff --git a/sale_stock_picking_blocking/tests/test_sale_stock_picking_blocking.py b/sale_stock_picking_blocking/tests/test_sale_stock_picking_blocking.py index b0248fa73f0..8e41d61b674 100644 --- a/sale_stock_picking_blocking/tests/test_sale_stock_picking_blocking.py +++ b/sale_stock_picking_blocking/tests/test_sale_stock_picking_blocking.py @@ -2,10 +2,10 @@ # (http://www.forgeflow.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo.exceptions import ValidationError -from odoo.tests import Form, common +from odoo.tests import Form, TransactionCase -class TestSaleDeliveryBlock(common.TransactionCase): +class TestSaleDeliveryBlock(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -28,15 +28,15 @@ def setUpClass(cls): # Create product: prod_dict = { "name": "test product", - "type": "product", + "type": "consu", + "categ_id": cls.env.ref('product.product_category_all').id, + "list_price": 100.0, + "standard_price": 60.0, + "uom_id": cls.env.ref('uom.product_uom_unit').id, + "uom_po_id": cls.env.ref('uom.product_uom_unit').id, } - product = cls.env["product.product"].with_user(cls.user_test).create(prod_dict) + cls.product = cls.env["product.product"].with_user(cls.user_test).create(prod_dict) # Create Sale order: - # TODO/TMP: - # - we explicitely add a name to avoid - # a weird issue occuring randomly during tests - # - seems related to sale_order_revision, - # further investigations ongoing so_dict = { "partner_id": cls.env.ref("base.res_partner_1").id, "name": "Test Sale Delivery Block", @@ -45,7 +45,7 @@ def setUpClass(cls): # Create Sale order lines: sol_dict = { "order_id": cls.sale_order.id, - "product_id": product.id, + "product_id": cls.product.id, "product_uom_qty": 1.0, } cls.sale_order_line = cls.sol_model.with_user(cls.user_test).create(sol_dict) @@ -129,3 +129,5 @@ def test_default_delivery_block_payment_term(self): so = so_form.save() self.assertEqual(so.delivery_block_id, block_reason) self.assertEqual(so.copy().delivery_block_id, block_reason) + print(self.env.context) + diff --git a/sale_stock_picking_blocking/views/sale_order_view.xml b/sale_stock_picking_blocking/views/sale_order_view.xml index dcde0e65288..507169039b5 100644 --- a/sale_stock_picking_blocking/views/sale_order_view.xml +++ b/sale_stock_picking_blocking/views/sale_order_view.xml @@ -36,7 +36,7 @@ sale.order - + diff --git a/sale_stock_picking_blocking/views/sale_stock_picking_blocking_reason_view.xml b/sale_stock_picking_blocking/views/sale_stock_picking_blocking_reason_view.xml index 18d5583acc2..c0e84f6bb47 100644 --- a/sale_stock_picking_blocking/views/sale_stock_picking_blocking_reason_view.xml +++ b/sale_stock_picking_blocking/views/sale_stock_picking_blocking_reason_view.xml @@ -4,14 +4,14 @@ - - sale.delivery.block.reason.tree + + sale.delivery.block.reason.list sale.delivery.block.reason - + - + @@ -44,7 +44,7 @@ AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).--> Sale Delivery Block Reason ir.actions.act_window sale.delivery.block.reason - tree,form + list,form