Skip to content

Commit

Permalink
[16.0][MIG] - sale_stock_picking_blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
sbejaoui committed Feb 8, 2023
1 parent 8348428 commit 0759ba0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 18 deletions.
6 changes: 3 additions & 3 deletions sale_stock_picking_blocking/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

{
"name": "Sale Stock Picking Blocking",
"summary": "Allow you to block the creation of deliveries " "from a sale order.",
"version": "15.0.1.0.1",
"author": "Eficent, " "Odoo Community Association (OCA)",
"summary": "Allow you to block the creation of deliveries from a sale order.",
"version": "16.0.1.0.0",
"author": "Eficent, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
"category": "Sales",
"depends": ["sale_stock"],
Expand Down
1 change: 1 addition & 0 deletions sale_stock_picking_blocking/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import sale_order
from . import sale_order_line
from . import sale_stock_picking_blocking_reason
from . import res_partner
17 changes: 3 additions & 14 deletions sale_stock_picking_blocking/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class SaleOrder(models.Model):
comodel_name="sale.delivery.block.reason",
tracking=True,
string="Delivery Block Reason",
readonly=True,
compute="_compute_delivery_block_id",
store=True,
states={"draft": [("readonly", False)], "sent": [("readonly", False)]},
)

Expand All @@ -26,12 +27,10 @@ def _check_not_auto_done(self):
)

@api.onchange("partner_id")
def onchange_partner_id(self):
def _compute_delivery_block_id(self):
"""Add the 'Default Delivery Block Reason' if set in the partner."""
res = super().onchange_partner_id()
for so in self:
so.delivery_block_id = so.partner_id.default_delivery_block or False
return res

def action_remove_delivery_block(self):
"""Remove the delivery block and create procurements as usual."""
Expand All @@ -49,13 +48,3 @@ def copy(self, default=None):
if so.partner_id.default_delivery_block and not so.delivery_block_id:
so.delivery_block_id = so.partner_id.default_delivery_block
return new_so


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

def _action_launch_stock_rule(self, previous_product_uom_qty=False):
return super(
SaleOrderLine,
self.filtered(lambda line: not line.order_id.delivery_block_id),
)._action_launch_stock_rule(previous_product_uom_qty=previous_product_uom_qty)
15 changes: 15 additions & 0 deletions sale_stock_picking_blocking/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2019 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import models


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

def _action_launch_stock_rule(self, previous_product_uom_qty=False):
return super(
SaleOrderLine,
self.filtered(lambda line: not line.order_id.delivery_block_id),
)._action_launch_stock_rule(previous_product_uom_qty=previous_product_uom_qty)
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ def test_default_delivery_block(self):
so_form.partner_id = partner_block
so = so_form.save()
self.assertEqual(so.delivery_block_id, block_reason)
self.assertEqual(so.copy_data()[0]["delivery_block_id"], block_reason.id)
self.assertEqual(so.copy().delivery_block_id, block_reason)
6 changes: 6 additions & 0 deletions setup/sale_stock_picking_blocking/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 0759ba0

Please sign in to comment.