diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2025-05-05 03:05:15 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2025-05-05 03:05:15 +0000 |
| commit | ca48d2fcffbb48d6b3a09360144a71101f6f41ef (patch) | |
| tree | 08769ff2dafb566042d8ecaaffff299c88aa699a /indoteknik_custom/models/sales_order_reject.py | |
| parent | 86cccc64c6f67b031a1bc345aae7922d83e021ea (diff) | |
| parent | 6dcc5e48adb87d43101eaa2e868d12356da092be (diff) | |
Merged in reject_line_new (pull request #283)
<miqdad> Removed product from order line moved to reject line
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 |
