Accept Merge Request #1641: (feature/销售订单优化 -> develop)
Merge Request: 销售订单供货方式为委外加工时生成的采购单问题优化 Created By: @禹翔辉 Reviewed By: @胡尧 Approved By: @胡尧 Accepted By: @禹翔辉 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1641?initial=true
This commit is contained in:
@@ -9,9 +9,9 @@ class StockRuleInherit(models.Model):
|
|||||||
@api.model
|
@api.model
|
||||||
def _run_buy(self, procurements):
|
def _run_buy(self, procurements):
|
||||||
# 判断补货组的采购类型
|
# 判断补货组的采购类型
|
||||||
procurements_group = {'standard': [], 'consignment': []}
|
procurements_group = {'standard': [], 'outsourcing': []}
|
||||||
for procurement, rule in procurements:
|
for procurement, rule in procurements:
|
||||||
is_consignment = False
|
is_outsourcing = False
|
||||||
product = procurement.product_id
|
product = procurement.product_id
|
||||||
# 获取主 BOM
|
# 获取主 BOM
|
||||||
bom = self.env['mrp.bom'].search([('product_tmpl_id', '=', product.product_tmpl_id.id)], limit=1)
|
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:
|
for route in raw_material.route_ids:
|
||||||
# print('route.name:', route.name)
|
# print('route.name:', route.name)
|
||||||
if route.name == '按订单补给外包商':
|
if route.name == '按订单补给外包商':
|
||||||
is_consignment = True
|
is_outsourcing = True
|
||||||
|
|
||||||
if is_consignment:
|
if is_outsourcing:
|
||||||
procurements_group['consignment'].append((procurement, rule))
|
procurements_group['outsourcing'].append((procurement, rule))
|
||||||
else:
|
else:
|
||||||
procurements_group['standard'].append((procurement, rule))
|
procurements_group['standard'].append((procurement, rule))
|
||||||
|
|
||||||
for key, value in procurements_group.items():
|
for key, value in procurements_group.items():
|
||||||
super(StockRuleInherit, self)._run_buy(value)
|
super(StockRuleInherit, self)._run_buy(value)
|
||||||
|
|
||||||
if key == 'consignment':
|
if key == 'outsourcing':
|
||||||
for procurement, rule in value:
|
for procurement, rule in value:
|
||||||
supplier = procurement.values.get('supplier')
|
supplier = procurement.values.get('supplier')
|
||||||
if supplier:
|
if supplier:
|
||||||
@@ -49,7 +49,7 @@ class StockRuleInherit(models.Model):
|
|||||||
], limit=1)
|
], limit=1)
|
||||||
logging.info("po=: %s", po)
|
logging.info("po=: %s", po)
|
||||||
if po:
|
if po:
|
||||||
po.write({'purchase_type': 'consignment'})
|
po.write({'purchase_type': 'outsourcing'})
|
||||||
|
|
||||||
# # 首先调用父类的 _run_buy 方法,以保留原有逻辑
|
# # 首先调用父类的 _run_buy 方法,以保留原有逻辑
|
||||||
# super(StockRuleInherit, self)._run_buy(procurements)
|
# super(StockRuleInherit, self)._run_buy(procurements)
|
||||||
@@ -83,5 +83,5 @@ class StockRuleInherit(models.Model):
|
|||||||
# ], limit=1)
|
# ], limit=1)
|
||||||
# logging.info("po=: %s", po)
|
# logging.info("po=: %s", po)
|
||||||
# if po:
|
# if po:
|
||||||
# po.write({'purchase_type': 'consignment'})
|
# po.write({'purchase_type': 'outsourcing'})
|
||||||
# break
|
# break
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class SFMessageSale(models.Model):
|
|||||||
purchase_order_info.add_queue('坯料采购提醒')
|
purchase_order_info.add_queue('坯料采购提醒')
|
||||||
purchase_order_ids = self.order_line.purchase_line_ids.order_id | self.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | self.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id
|
purchase_order_ids = self.order_line.purchase_line_ids.order_id | self.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | self.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id
|
||||||
for purchase_order_id in purchase_order_ids:
|
for purchase_order_id in purchase_order_ids:
|
||||||
if purchase_order_id.purchase_type == 'consignment':
|
if purchase_order_id.purchase_type == 'outsourcing':
|
||||||
purchase_order_id.add_queue('委外加工采购单提醒')
|
purchase_order_id.add_queue('委外加工采购单提醒')
|
||||||
if purchase_order_id.purchase_type == 'standard':
|
if purchase_order_id.purchase_type == 'standard':
|
||||||
purchase_order_id.add_queue('外购订单采购单提醒')
|
purchase_order_id.add_queue('外购订单采购单提醒')
|
||||||
|
|||||||
@@ -170,9 +170,9 @@ class ReSaleOrder(models.Model):
|
|||||||
def _compute_purchase_order_count(self):
|
def _compute_purchase_order_count(self):
|
||||||
for order in self:
|
for order in self:
|
||||||
order.purchase_order_count = len(order._get_purchase_orders().filtered(
|
order.purchase_order_count = len(order._get_purchase_orders().filtered(
|
||||||
lambda po: po.purchase_type not in ['consignment']))
|
lambda po: po.purchase_type not in ['outsourcing']))
|
||||||
order.consignment_purchase_order_count = len(order._get_purchase_orders().filtered(
|
order.consignment_purchase_order_count = len(order._get_purchase_orders().filtered(
|
||||||
lambda po: po.purchase_type in ['consignment']))
|
lambda po: po.purchase_type in ['outsourcing']))
|
||||||
|
|
||||||
def action_view_purchase_orders(self):
|
def action_view_purchase_orders(self):
|
||||||
"""
|
"""
|
||||||
@@ -180,7 +180,7 @@ class ReSaleOrder(models.Model):
|
|||||||
"""
|
"""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
purchase_order_ids = self._get_purchase_orders().filtered(
|
purchase_order_ids = self._get_purchase_orders().filtered(
|
||||||
lambda po: po.purchase_type not in ['consignment']).ids
|
lambda po: po.purchase_type not in ['outsourcing']).ids
|
||||||
action = {
|
action = {
|
||||||
'res_model': 'purchase.order',
|
'res_model': 'purchase.order',
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
@@ -203,21 +203,21 @@ class ReSaleOrder(models.Model):
|
|||||||
委外加工
|
委外加工
|
||||||
"""
|
"""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
consignment_purchase_order_ids = self._get_purchase_orders().filtered(
|
outsourcing_purchase_order_ids = self._get_purchase_orders().filtered(
|
||||||
lambda po: po.purchase_type in ['consignment']).ids
|
lambda po: po.purchase_type in ['outsourcing']).ids
|
||||||
action = {
|
action = {
|
||||||
'res_model': 'purchase.order',
|
'res_model': 'purchase.order',
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
}
|
}
|
||||||
if len(consignment_purchase_order_ids) == 1:
|
if len(outsourcing_purchase_order_ids) == 1:
|
||||||
action.update({
|
action.update({
|
||||||
'view_mode': 'form',
|
'view_mode': 'form',
|
||||||
'res_id': consignment_purchase_order_ids[0],
|
'res_id': outsourcing_purchase_order_ids[0],
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
action.update({
|
action.update({
|
||||||
'name': _("从 %s生成委外加工订单", self.name),
|
'name': _("从 %s生成委外加工订单", self.name),
|
||||||
'domain': [('id', 'in', consignment_purchase_order_ids)],
|
'domain': [('id', 'in', outsourcing_purchase_order_ids)],
|
||||||
'view_mode': 'tree,form',
|
'view_mode': 'tree,form',
|
||||||
})
|
})
|
||||||
return action
|
return action
|
||||||
|
|||||||
Reference in New Issue
Block a user