Skip to content

Commit

Permalink
[FIX] sale_order_line_date : use default date to propagate if commitm…
Browse files Browse the repository at this point in the history
…ent date is removed on the sale order line
  • Loading branch information
metaminux committed Oct 16, 2024
1 parent 58e8904 commit 0b5dd65
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions sale_order_line_date/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ def _prepare_procurement_values(self, group_id=False):

def write(self, vals):
res = super().write(vals)
moves_to_upd = set()
if "commitment_date" in vals:
for move in self.move_ids:
if move.state not in ["cancel", "done"]:
moves_to_upd.add(move.id)
if moves_to_upd:
self.env["stock.move"].browse(moves_to_upd).write(
{"date_deadline": vals.get("commitment_date")}
)
if vals.get("commitment_date"):
self.move_ids.filtered(
lambda sm: sm.state not in ["cancel", "done"]
).write({"date_deadline": vals.get("commitment_date")})
else:
for line in self:
date_deadline = (
line.order_id.commitment_date or line._expected_date()
)
line.move_ids.filtered(
lambda sm: sm.state not in ["cancel", "done"]
).write({"date_deadline": date_deadline})
return res

0 comments on commit 0b5dd65

Please sign in to comment.