From a00faa739bdbd8d7750728bdfdc3926b9bf446e2 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 13 Oct 2023 15:38:18 +0700 Subject: sale monitoring upgrade --- indoteknik_custom/models/sale_monitoring.py | 34 ++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/sale_monitoring.py') diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index ad15e0c2..cac68b7c 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -21,9 +21,41 @@ 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", compute='compute_note') + note_so_line = fields.Selection([ + ('eta', 'ETA'), + ('info_sales', 'Info Sales'), + ('info_vendor', 'Info Vendor'), + ('penggabungan', 'Penggabungan'), + ], string="Note", compute='compute_note') + note = fields.Char(string="Note Detail", compute='compute_note_detail') + purchase_representative_id = fields.Many2one('res.users', string="Purchase Representative", readonly=True, compute='compute_purchase_representative') + + def compute_purchase_representative(self): + for sale in self: + po = self.env['purchase.order'].search([ + ('sale_order_id', '=', sale.sale_order_id.id), + ('user_id', '!=', False) + ]) + + user_id = False + + if po: + user_id = po[0].user_id + + sale.purchase_representative_id = user_id def compute_note(self): + for sale in self: + lines = self.env['sale.order.line'].search([ + ('order_id', '=', sale.sale_order_id.id), + ('note', '!=', False) + ]) + + note = ', '.join(lines.mapped('note') or ['']) + + sale.note_so_line = note + + def compute_note_detail(self): for sale in self: lines = self.env['sale.order.line'].search([ ('order_id', '=', sale.sale_order_id.id), -- cgit v1.2.3 From 21fdc9e5023924e40159c5c0227bc549b23b5c2f Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 16 Oct 2023 08:21:28 +0700 Subject: fix error monitoring --- indoteknik_custom/models/sale_monitoring.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'indoteknik_custom/models/sale_monitoring.py') diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index cac68b7c..e3959da0 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -26,7 +26,7 @@ class SaleMonitoring(models.Model): ('info_sales', 'Info Sales'), ('info_vendor', 'Info Vendor'), ('penggabungan', 'Penggabungan'), - ], string="Note", compute='compute_note') + ], string="Note") note = fields.Char(string="Note Detail", compute='compute_note_detail') purchase_representative_id = fields.Many2one('res.users', string="Purchase Representative", readonly=True, compute='compute_purchase_representative') @@ -44,16 +44,6 @@ class SaleMonitoring(models.Model): sale.purchase_representative_id = user_id - def compute_note(self): - for sale in self: - lines = self.env['sale.order.line'].search([ - ('order_id', '=', sale.sale_order_id.id), - ('note', '!=', False) - ]) - - note = ', '.join(lines.mapped('note') or ['']) - - sale.note_so_line = note def compute_note_detail(self): for sale in self: -- cgit v1.2.3 From eefe129e31b112d80038fc3aecf2aee4c4e10108 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 16 Oct 2023 08:34:02 +0700 Subject: fix sale monitoring --- indoteknik_custom/models/sale_monitoring.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/sale_monitoring.py') diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index e3959da0..cfbe6d78 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -26,7 +26,7 @@ class SaleMonitoring(models.Model): ('info_sales', 'Info Sales'), ('info_vendor', 'Info Vendor'), ('penggabungan', 'Penggabungan'), - ], string="Note") + ], string="Note", compute='compute_note') note = fields.Char(string="Note Detail", compute='compute_note_detail') purchase_representative_id = fields.Many2one('res.users', string="Purchase Representative", readonly=True, compute='compute_purchase_representative') @@ -44,6 +44,14 @@ class SaleMonitoring(models.Model): sale.purchase_representative_id = user_id + def compute_note(self): + for sale in self: + lines = self.env['sale.order.line'].search([ + ('order_id', '=', sale.sale_order_id.id), + ('note', '!=', False) + ], limit=1) + + sale.note_so_line = lines.note def compute_note_detail(self): for sale in self: -- cgit v1.2.3 From d426ff142df8b5778398e3b460ff03d02d9e368a Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 30 Oct 2023 11:38:13 +0700 Subject: move status invoiced to bottom in sale monitoring header only --- indoteknik_custom/models/sale_monitoring.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/sale_monitoring.py') diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index cfbe6d78..107d5296 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -81,12 +81,12 @@ class SaleMonitoring(models.Model): SUM(smd.qty_so_invoiced) AS qty_so_invoiced, sum(smd.qty_reserved) as qty_reserved, CASE - when sum(qty_so_invoiced) = sum(qty_so) then 'Invoiced' when sum(qty_so_delivered) = sum(qty_so) then 'Delivered' when sum(qty_reserved) >= sum(qty_so) then 'Siap kirim' when sum(qty_po) + sum(qty_reserved) - sum(qty_po_received) < sum(qty_so) then 'Belum/Kurang PO' when sum(qty_po_received) = 0 then 'Belum terima' when sum(qty_po_received) < sum(qty_po) then 'Terima sebagian' + when sum(qty_so_invoiced) = sum(qty_so) then 'Invoiced' END AS status, get_po_number(smd.sale_order_id) as po_number FROM sale_monitoring_detail smd -- cgit v1.2.3