[FIX] purchase: Prevents logging a qty update when qty isn't updated

closes odoo/odoo#110905

X-original-commit: dbf526ba37e0e34a569aee079e4cd65b24a6d6d0
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
Cyril Dutrieux (cydu)
2023-02-02 15:02:10 +01:00
parent 42a57110eb
commit 768a2e438f
+6 -1
View File
@@ -1096,13 +1096,18 @@ class PurchaseOrderLine(models.Model):
raise UserError(_("You cannot change the type of a purchase order line. Instead you should delete the current line and create a new line of the proper type."))
if 'product_qty' in values:
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
for line in self:
if line.order_id.state == 'purchase':
if (
line.order_id.state == "purchase"
and float_compare(line.product_qty, values["product_qty"], precision_digits=precision) != 0
):
line.order_id.message_post_with_source(
'purchase.track_po_line_template',
render_values={'line': line, 'product_qty': values['product_qty']},
subtype_xmlid='mail.mt_note',
)
if 'qty_received' in values:
for line in self:
line._track_qty_received(values['qty_received'])