Skip to content

Commit

Permalink
[MIG] sale_stock_picking_blocking: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
absal-smile committed Jan 30, 2025
1 parent 95552bb commit 7bf6de5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
6 changes: 3 additions & 3 deletions sale_stock_picking_blocking/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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",
Expand All @@ -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)
Expand Down Expand Up @@ -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)

2 changes: 1 addition & 1 deletion sale_stock_picking_blocking/views/sale_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_sales_order_filter" />
<field name="arch" type="xml">
<field name="analytic_account_id" position="after">
<field name="team_id" position="after">
<field name="delivery_block_id" />
</field>
<filter name="my_sale_orders_filter" position="after">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<!--License
AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).-->
<odoo>
<record id="sale_stock_picking_blocking_reason_tree_view" model="ir.ui.view">
<field name="name">sale.delivery.block.reason.tree</field>
<record id="sale_stock_picking_blocking_reason_list_view" model="ir.ui.view">
<field name="name">sale.delivery.block.reason.list</field>
<field name="model">sale.delivery.block.reason</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
<field name="description" />
</tree>
</list>
</field>
</record>
<record id="sale_stock_picking_blocking_reason_form_view" model="ir.ui.view">
Expand Down Expand Up @@ -44,7 +44,7 @@ AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).-->
<field name="name">Sale Delivery Block Reason</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.delivery.block.reason</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
</record>
<menuitem
id="menu_sale_stock_picking_blocking_reason"
Expand Down

0 comments on commit 7bf6de5

Please sign in to comment.