1、销售订单供货方式为委外加工时生成的采购单问题优化
This commit is contained in:
@@ -9,9 +9,9 @@ class StockRuleInherit(models.Model):
|
||||
@api.model
|
||||
def _run_buy(self, procurements):
|
||||
# 判断补货组的采购类型
|
||||
procurements_group = {'standard': [], 'consignment': []}
|
||||
procurements_group = {'standard': [], 'outsourcing': []}
|
||||
for procurement, rule in procurements:
|
||||
is_consignment = False
|
||||
is_outsourcing = False
|
||||
product = procurement.product_id
|
||||
# 获取主 BOM
|
||||
bom = self.env['mrp.bom'].search([('product_tmpl_id', '=', product.product_tmpl_id.id)], limit=1)
|
||||
@@ -24,17 +24,17 @@ class StockRuleInherit(models.Model):
|
||||
for route in raw_material.route_ids:
|
||||
# print('route.name:', route.name)
|
||||
if route.name == '按订单补给外包商':
|
||||
is_consignment = True
|
||||
is_outsourcing = True
|
||||
|
||||
if is_consignment:
|
||||
procurements_group['consignment'].append((procurement, rule))
|
||||
if is_outsourcing:
|
||||
procurements_group['outsourcing'].append((procurement, rule))
|
||||
else:
|
||||
procurements_group['standard'].append((procurement, rule))
|
||||
|
||||
for key, value in procurements_group.items():
|
||||
super(StockRuleInherit, self)._run_buy(value)
|
||||
|
||||
if key == 'consignment':
|
||||
if key == 'outsourcing':
|
||||
for procurement, rule in value:
|
||||
supplier = procurement.values.get('supplier')
|
||||
if supplier:
|
||||
@@ -49,7 +49,7 @@ class StockRuleInherit(models.Model):
|
||||
], limit=1)
|
||||
logging.info("po=: %s", po)
|
||||
if po:
|
||||
po.write({'purchase_type': 'consignment'})
|
||||
po.write({'purchase_type': 'outsourcing'})
|
||||
|
||||
# # 首先调用父类的 _run_buy 方法,以保留原有逻辑
|
||||
# super(StockRuleInherit, self)._run_buy(procurements)
|
||||
@@ -83,5 +83,5 @@ class StockRuleInherit(models.Model):
|
||||
# ], limit=1)
|
||||
# logging.info("po=: %s", po)
|
||||
# if po:
|
||||
# po.write({'purchase_type': 'consignment'})
|
||||
# po.write({'purchase_type': 'outsourcing'})
|
||||
# break
|
||||
|
||||
Reference in New Issue
Block a user