summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/stock_picking.py
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-02-10 14:45:54 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-02-10 14:45:54 +0700
commit3de9e2a7e2b9b455fa85e33231612996538830f4 (patch)
treec31cd2576cc20a1655af84eda29335d67b216c90 /indoteknik_custom/models/stock_picking.py
parent519d2466e550ccf382466b8bb46af84169f3267b (diff)
parentdec973e8e6b8647e8762ab6ce32d90df371cd24b (diff)
Merge branch 'release' of bitbucket.org:altafixco/indoteknik-addons into release
Diffstat (limited to 'indoteknik_custom/models/stock_picking.py')
-rw-r--r--indoteknik_custom/models/stock_picking.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 9599548c..4049c535 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