Accept Merge Request #1812: (feature/制造功能优化 -> develop)
Merge Request: 完善取消订单功能 Created By: @马广威 Accepted By: @马广威 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1812?initial=true
This commit is contained in:
@@ -34,17 +34,17 @@ class SFSaleOrderCancelWizard(models.TransientModel):
|
|||||||
|
|
||||||
def action_confirm_cancel(self):
|
def action_confirm_cancel(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
|
||||||
# 取消销售订单关联的采购单
|
# 取消销售订单关联的采购单
|
||||||
purchase_orders = self.env['purchase.order'].search([
|
purchase_orders = self.env['purchase.order'].search([
|
||||||
('origin', '=', self.order_id.name)
|
('origin', '=', self.order_id.name)
|
||||||
])
|
])
|
||||||
if purchase_orders:
|
if purchase_orders:
|
||||||
purchase_orders.write({'state': 'cancel'})
|
purchase_orders.write({'state': 'cancel'})
|
||||||
|
|
||||||
# 取消销售订单
|
# 取消销售订单
|
||||||
result = self.order_id.action_cancel()
|
result = self.order_id.action_cancel()
|
||||||
|
|
||||||
# 取消关联的制造订单及其采购单
|
# 取消关联的制造订单及其采购单
|
||||||
manufacturing_orders = self.env['mrp.production'].search([
|
manufacturing_orders = self.env['mrp.production'].search([
|
||||||
('origin', '=', self.order_id.name)
|
('origin', '=', self.order_id.name)
|
||||||
@@ -56,13 +56,20 @@ class SFSaleOrderCancelWizard(models.TransientModel):
|
|||||||
])
|
])
|
||||||
if mo_purchase_orders:
|
if mo_purchase_orders:
|
||||||
mo_purchase_orders.write({'state': 'cancel'})
|
mo_purchase_orders.write({'state': 'cancel'})
|
||||||
|
|
||||||
|
# 取消制造订单的质检单
|
||||||
|
mo_quality_checks = self.env['quality.check'].search([
|
||||||
|
('production_id', '=', mo.id)
|
||||||
|
])
|
||||||
|
if mo_quality_checks:
|
||||||
|
mo_quality_checks.write({'state': 'cancel'})
|
||||||
|
|
||||||
# 取消制造订单
|
# 取消制造订单
|
||||||
mo.action_cancel()
|
mo.action_cancel()
|
||||||
|
|
||||||
# 取消制造订单关联的编程单
|
# 取消制造订单关联的编程单
|
||||||
mo._change_programming_state()
|
mo._change_programming_state()
|
||||||
|
|
||||||
# 取消组件的制造单关联的采购单
|
# 取消组件的制造单关联的采购单
|
||||||
for comp_mo in self.env['mrp.production'].search([
|
for comp_mo in self.env['mrp.production'].search([
|
||||||
('origin', '=', mo.name)
|
('origin', '=', mo.name)
|
||||||
@@ -72,9 +79,10 @@ class SFSaleOrderCancelWizard(models.TransientModel):
|
|||||||
])
|
])
|
||||||
if comp_purchase_orders:
|
if comp_purchase_orders:
|
||||||
comp_purchase_orders.button_cancel()
|
comp_purchase_orders.button_cancel()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
class SFSaleOrderCancelLine(models.TransientModel):
|
class SFSaleOrderCancelLine(models.TransientModel):
|
||||||
_name = 'sf.sale.order.cancel.line'
|
_name = 'sf.sale.order.cancel.line'
|
||||||
_description = '销售订单取消行'
|
_description = '销售订单取消行'
|
||||||
@@ -103,7 +111,9 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
|||||||
'pending': '等待其他工单',
|
'pending': '等待其他工单',
|
||||||
'none': '待处理',
|
'none': '待处理',
|
||||||
'draft': '报价',
|
'draft': '报价',
|
||||||
'cancel': '已取消'
|
'cancel': '已取消',
|
||||||
|
'pass': '通过的',
|
||||||
|
'fail': '失败的'
|
||||||
}
|
}
|
||||||
|
|
||||||
# 检查销售订单
|
# 检查销售订单
|
||||||
@@ -237,7 +247,8 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
|||||||
'product_name': mo.product_id.name,
|
'product_name': mo.product_id.name,
|
||||||
'quantity': workorder.qty_production,
|
'quantity': workorder.qty_production,
|
||||||
'doc_state': map_dict.get(workorder.state, workorder.state),
|
'doc_state': map_dict.get(workorder.state, workorder.state),
|
||||||
'cancel_reason': '已有异动' if workorder.state not in ['draft', 'cancel', 'pending', 'waiting'] else ''
|
'cancel_reason': '已有异动' if workorder.state not in ['draft', 'cancel', 'pending',
|
||||||
|
'waiting'] else ''
|
||||||
}
|
}
|
||||||
lines.append(self.create(vals))
|
lines.append(self.create(vals))
|
||||||
sequence += 1
|
sequence += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user