Skip to content

Commit

Permalink
Merge PR #125 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by jbaudoux
  • Loading branch information
OCA-git-bot committed Oct 11, 2024
2 parents b3646cb + 1be721d commit ddeebc5
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions shipment_advice_bill_auto_complete/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,45 @@ def _get_purchase_quantity_from_stock_move_line(self, po_line, move_lines):
if move_lines.product_id == po_line.product_id:
quantity_done = sum(move_lines.mapped("qty_done"))
return quantity_done

@api.model_create_multi
def create(self, vals_list):
moves = super().create(vals_list)
for move in moves:
if move.move_type not in ("in_invoice", "out_refund"):
continue
shipment = move.line_ids.mapped("shipment_advice_id")
if not shipment:
continue
refs = [
"<a href=# data-oe-model=shipment.advice data-oe-id=%s>%s</a>"
% tuple(name_get)
for name_get in shipment.name_get()
]
message = _("This vendor bill has been created from: %s") % ",".join(refs)
move.message_post(body=message)
return moves

def write(self, vals):
old_shipment = {
move.id: move.mapped("line_ids.shipment_advice_id") for move in self
}
res = super().write(vals)
for move in self:
if move.move_type not in ("in_invoice", "out_refund"):
continue
new_shipment = move.mapped("line_ids.shipment_advice_id")
if not new_shipment:
continue
diff_shipments = new_shipment - old_shipment[move.id]
if diff_shipments:
refs = [
"<a href=# data-oe-model=shipment.advice data-oe-id=%s>%s</a>"
% tuple(name_get)
for name_get in diff_shipments.name_get()
]
message = _("This vendor bill has been modified from: %s") % ",".join(
refs
)
move.message_post(body=message)
return res

0 comments on commit ddeebc5

Please sign in to comment.