diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-05-31 14:09:59 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-05-31 14:09:59 +0700 |
| commit | 21f7c7a9b5ad175994b0824f82f9459feed3ca90 (patch) | |
| tree | d3ba50005ef33b1e8c9e54ca3a713831ac28ea9b | |
| parent | 095e0a6815bcc64d638d64f72f5f392aa92ec7b6 (diff) | |
add calculate all so status function
| -rwxr-xr-x | indoteknik_custom/models/sale_monitoring_detail.py | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py index 6c609ac2..a578f67b 100755 --- a/indoteknik_custom/models/sale_monitoring_detail.py +++ b/indoteknik_custom/models/sale_monitoring_detail.py @@ -60,7 +60,7 @@ class SaleMonitoringDetail(models.Model): WHERE pt.type IN ('consu','product') AND so.state IN ('sale','done') AND so.create_date >= '2022-08-10' - and (so.so_status not in('terproses') or so.invoice_status not in('invoiced')) + and so.so_status not in('terproses') ) a ) """ % self._table) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 85d7e595..d7b4331a 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -116,6 +116,33 @@ class SaleOrder(models.Model): sale.so_status = 'terproses' _logger.info('Calculate SO Status %s' % sale.id) + def _calculate_all_so_status(self, limit=500): + so_state = ['sale'] + sales = self.env['sale.order'].search([ + ('state', 'in', so_state), + # ('so_status', '!=', 'terproses'), + ], order='id desc', limit=limit) + for sale in sales: + sum_qty_ship = sum_qty_so = 0 + have_outstanding_pick = False + + for pick in sale.picking_ids: + if pick.state == 'draft' or pick.state == 'assigned' or pick.state == 'confirmed' or pick.state == 'waiting': + have_outstanding_pick = True + + for so_line in sale.order_line: + sum_qty_so += so_line.product_uom_qty + sum_qty_ship += so_line.qty_delivered + + if have_outstanding_pick: + if sum_qty_so > sum_qty_ship > 0: + sale.so_status = 'sebagian' + else: + sale.so_status = 'menunggu' + else: + sale.so_status = 'terproses' + _logger.info('Calculate All SO Status %s' % sale.id) + def calculate_so_status(self): so_state = ['sale'] sales = self.env['sale.order'].search([ |
