From b87787893d25f735bdf9aba164bc8b1f23e2b72f Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 10 Feb 2023 15:26:25 +0700 Subject: fix line number in po/so and stock picking --- indoteknik_custom/models/stock_move.py | 6 ++++++ indoteknik_custom/models/stock_picking.py | 13 ++++++------- indoteknik_custom/views/stock_picking.xml | 8 -------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py index 869053d7..22a73010 100644 --- a/indoteknik_custom/models/stock_move.py +++ b/indoteknik_custom/models/stock_move.py @@ -33,3 +33,9 @@ class StockMove(models.Model): new_account_move._post() return True return super(StockMove, self)._create_account_move_line(credit_account_id, debit_account_id, journal_id, qty, description, svl_id, cost) + + +class StockMoveLine(models.Model): + _inherit = 'stock.move.line' + + line_no = fields.Integer('No', default=0) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 4049c535..2c75ccbc 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -96,24 +96,23 @@ class StockPicking(models.Model): def calculate_line_no(self): for picking in self: - for line in picking.move_ids_without_package: - # order_lines = picking.group_id.order_line - name = picking.group_id.name + name = picking.group_id.name + for move in picking.move_ids_without_package: 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: + if move.product_id == order_line.product_id: set_line = order_line.line_no break else: continue - line.line_no = set_line + move.line_no = set_line + for line in move.move_line_ids: + line.line_no = set_line def _compute_summary_qty(self): sum_qty_detail = sum_qty_operation = count_line_detail = count_line_operation = 0 diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 49e594b1..a189e399 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -31,14 +31,6 @@ attrs="{'invisible': ['|', ('state', '=', 'draft'), ('state', '=', 'cancel'), ('approval_return_status', '=', 'pengajuan1')]}" /> -
-