diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-02-10 11:04:07 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-02-10 11:04:07 +0700 |
| commit | 337e769c7eab63275b4114f48e789bdcf808bdf1 (patch) | |
| tree | 24f09636ecd83abcc22f53295c905d637801b437 /indoteknik_custom/models | |
| parent | bbf176b0ce51ade22b74d0df2023025a4cef3efa (diff) | |
add line no in so / po and stock picking
Diffstat (limited to 'indoteknik_custom/models')
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 23 |
3 files changed, 21 insertions, 5 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index b4d671b6..2f3d2ec4 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -169,6 +169,8 @@ class PurchaseOrder(models.Model): self.approval_status = 'approved' self.po_status = 'menunggu' + self.calculate_line_no() + return res def po_approve(self): diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index e85454da..f21554f7 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -281,6 +281,7 @@ class SaleOrder(models.Model): raise UserError("Harus diapprove oleh Manager") else: order.approval_status = 'approved' + order.calculate_line_no() return res diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 8a0ad71e..180e2500 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -95,13 +95,25 @@ class StockPicking(models.Model): pick.approval_return_status = 'pengajuan1' def calculate_line_no(self): - line_no = 0 for picking in self: for line in picking.move_ids_without_package: - if line.product_id.type == 'product': - line_no += 1 - line.line_no = line_no - # _logger.info('Calculate PO Line No %s' % line.id) + # order_lines = picking.group_id.order_line + name = picking.group_id.name + if picking.group_id.sale_id: + order = self.env['sale.order'].search([('name', '=', name)], limit=1) + else: + order = self.env['purchase.order'].search([('name', '=', name)], limit=1) + + order_lines = order.order_line + set_line = 0 + + for order_line in order_lines: + if line.product_id == order_line.product_id: + set_line = order_line.line_no + break + else: + continue + line.line_no = set_line def _compute_summary_qty(self): sum_qty_detail = sum_qty_operation = count_line_detail = count_line_operation = 0 @@ -153,6 +165,7 @@ class StockPicking(models.Model): self.approval_status = 'approved' res = super(StockPicking, self).button_validate() + self.calculate_line_no() return res @api.model |
