diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-05-05 17:03:17 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-05-05 17:03:17 +0700 |
| commit | 0200cf2b4aa6a02a0bd31240b2c263193a638ede (patch) | |
| tree | dbb40448fb50f0f3fa709e32bc2cd337503455ae /indoteknik_custom/models/sales_order_reject.py | |
| parent | fcc0596b649ef53a6280530b60c89a2a0dc0ebec (diff) | |
| parent | 2bd00a536bc314075a8a472cf5e36f80d7d72c8a (diff) | |
Merge branch 'odoo-backup' of bitbucket.org:altafixco/indoteknik-addons into odoo-backup
# Conflicts:
# indoteknik_custom/models/stock_picking.py
Diffstat (limited to 'indoteknik_custom/models/sales_order_reject.py')
| -rw-r--r-- | indoteknik_custom/models/sales_order_reject.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/indoteknik_custom/models/sales_order_reject.py b/indoteknik_custom/models/sales_order_reject.py index 9983c64e..b180fad6 100644 --- a/indoteknik_custom/models/sales_order_reject.py +++ b/indoteknik_custom/models/sales_order_reject.py @@ -13,3 +13,30 @@ class SalesOrderReject(models.Model): product_id = fields.Many2one('product.product', string='Product') qty_reject = fields.Float(string='Qty') reason_reject = fields.Char(string='Reason Reject') + + def write(self, vals): + # Check if reason_reject is being updated + if 'reason_reject' in vals: + for record in self: + old_reason = record.reason_reject + new_reason = vals['reason_reject'] + + # Only post a message if the reason actually changed + if old_reason != new_reason: + now = fields.Datetime.now() + + # Create the log note for the updated reason + log_note = (f"<li>Product '{record.product_id.name}' rejection reason updated:</li>" + f"<li>From: {old_reason}</li>" + f"<li>To: {new_reason}</li>" + f"<li>Updated on: {now.strftime('%d-%m-%Y')} at {now.strftime('%H:%M:%S')}</li>") + + # Post ke lognote + if record.sale_order_id: + record.sale_order_id.message_post( + body=log_note, + author_id=self.env.user.partner_id.id, + ) + + # Call the original write method + return super(SalesOrderReject, self).write(vals)
\ No newline at end of file |
