Skip to content

Commit

Permalink
[FIX] purchase_manual_delivery: changing order line quantity created …
Browse files Browse the repository at this point in the history
…the delivery
  • Loading branch information
StefanRijnhart committed Feb 18, 2025
1 parent 0e4d594 commit 68afb36
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions purchase_manual_delivery/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Contributors
------------

- Adria Gil Sorribes <[email protected]>
- Stefan Rijnhart <[email protected]>

Maintainers
-----------
Expand Down
1 change: 1 addition & 0 deletions purchase_manual_delivery/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def _compute_pending_to_receive(self):
order.pending_to_receive = False

def _create_picking(self):
# Avoid creating deliveries on manual delivery orders
if self.env.context.get("ignore_manual_delivery"):
orders = self
else:
Expand Down
8 changes: 8 additions & 0 deletions purchase_manual_delivery/models/purchase_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,11 @@ def _compute_qty_in_receipt(self):
line.pending_to_receive = True
else:
line.pending_to_receive = False

def _create_or_update_picking(self):
# Avoid creating deliveries on manual delivery orders
if self.env.context.get("ignore_manual_delivery"):
lines = self
else:
lines = self.filtered(lambda pol: not pol.order_id.manual_delivery)
return super(PurchaseOrderLine, lines)._create_or_update_picking()
1 change: 1 addition & 0 deletions purchase_manual_delivery/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Adria Gil Sorribes \<<[email protected]>\>
- Stefan Rijnhart \<<[email protected]>\>
1 change: 1 addition & 0 deletions purchase_manual_delivery/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>Adria Gil Sorribes &lt;<a class="reference external" href="mailto:adria.gil&#64;forgeflow.com">adria.gil&#64;forgeflow.com</a>&gt;</li>
<li>Stefan Rijnhart &lt;<a class="reference external" href="mailto:stefan&#64;opener.amsterdam">stefan&#64;opener.amsterdam</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
26 changes: 26 additions & 0 deletions purchase_manual_delivery/tests/test_purchase_manual_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,29 @@ def test_07_purchase_order_ignore_manual_delivery(self):
line.pending_to_receive,
"Context key did not create stock moves for all quantities",
)

def test_08_purchase_order_line_increase_quantity(self):
"""Increasing the quantity on a confirmed line does not trigger delivery"""
self.po1.button_confirm()
self.assertFalse(self.po1.picking_ids)
self.po1.order_line[0].product_qty += 1
self.assertFalse(
self.po1.picking_ids,
"Increasing the quantity on a confirmed line should not create deliveries",
)
# Same on line creation
self.po1.order_line[0].copy()
self.assertFalse(self.po1.picking_ids)
self.assertFalse(
self.po1.picking_ids,
"Adding a line to a confirmed order should not create a delivery",
)
# Context key forces the delivery
self.po1.order_line[0].with_context(
ignore_manual_delivery=True
).product_qty += 1
self.assertTrue(
self.po1.picking_ids,
"Passing context key when increasing the quantity on a confirmed line did "
"not create a delivery",
)

0 comments on commit 68afb36

Please sign in to comment.