diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-10-06 14:47:45 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-10-06 14:47:45 +0700 |
| commit | 32d8b6e9655dcd19eb368333aadb565f29a9079b (patch) | |
| tree | 269434f3436c110acd12235e258aa19585f4909a | |
| parent | 5f9c6e2837c8201ca8132f3d3d71627bf799fb6d (diff) | |
compute note sale monitoring
| -rwxr-xr-x | indoteknik_custom/models/sale_monitoring.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index 587be436..ad15e0c2 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -21,7 +21,18 @@ class SaleMonitoring(models.Model): status = fields.Char(string="Status") po_number = fields.Char(string="PO Number") qty_reserved = fields.Integer(string="Qty Reserved") - note = fields.Char(string="Note", related='sale_order_id.order_line.note_procurement') + note = fields.Char(string="Note", compute='compute_note') + + def compute_note(self): + for sale in self: + lines = self.env['sale.order.line'].search([ + ('order_id', '=', sale.sale_order_id.id), + ('note_procurement', '!=', False) + ]) + + note_procurement = ', '.join(lines.mapped('note_procurement') or ['']) + + sale.note = note_procurement def init(self): tools.drop_view_if_exists(self.env.cr, self._table) |
