summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/sales_order_reject.py
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2025-05-27 10:19:09 +0700
committerit-fixcomart <it@fixcomart.co.id>2025-05-27 10:19:09 +0700
commitf0f414383b3bd34e6fce12e68e171014c08d2a55 (patch)
treef9eef4c1331f6507fadc680bdd801656ff9f8ea7 /indoteknik_custom/models/sales_order_reject.py
parent431229f2a6f1203fbdfe470229e55da8ebd3ea01 (diff)
parentd3f530b94569059106164172485aaa9665e80709 (diff)
Merge branch 'odoo-backup' into CR/repeat-order
Diffstat (limited to 'indoteknik_custom/models/sales_order_reject.py')
-rw-r--r--indoteknik_custom/models/sales_order_reject.py27
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