From 32d8b6e9655dcd19eb368333aadb565f29a9079b Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 6 Oct 2023 14:47:45 +0700 Subject: compute note sale monitoring --- indoteknik_custom/models/sale_monitoring.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3