sf-工厂取消接单-坯料的制造订单未取消
This commit is contained in:
@@ -275,9 +275,9 @@ class MrpProduction(models.Model):
|
||||
@api.onchange('product_id')
|
||||
def onchange_product_id(self):
|
||||
for record in self:
|
||||
if record.product_id.categ_id.type == '成品':
|
||||
if record.product_id.categ_id.name == '成品':
|
||||
record.production_product_type = '成品'
|
||||
elif record.product_id.categ_id.type == '坯料':
|
||||
elif record.product_id.categ_id.name == '坯料':
|
||||
record.production_product_type = '坯料'
|
||||
else:
|
||||
record.production_product_type = '其他'
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
</xpath>
|
||||
<xpath expr="//sheet//group//group//div[3]" position="after">
|
||||
<field name="production_type" readonly="1"/>
|
||||
<field name="production_product_type" readonly="1" invisible="1"/>
|
||||
<field name="production_product_type" invisible="1"/>
|
||||
<field name="manual_quotation" readonly="1"
|
||||
attrs="{'invisible': [('production_type', 'not in', ['自动化产线加工', '人工线下加工']), ('production_product_type', '!=', '成品')]}"/>
|
||||
<field name="programming_no" readonly="1"
|
||||
|
||||
@@ -36,7 +36,7 @@ class SFSaleOrderCancelWizard(models.TransientModel):
|
||||
if not wizard.related_docs:
|
||||
wizard.display_message = '无下游单据'
|
||||
continue
|
||||
|
||||
|
||||
# 检查是否所有记录都是已取消状态
|
||||
all_canceled = all(doc.doc_state == '已取消' for doc in wizard.related_docs)
|
||||
if all_canceled:
|
||||
@@ -76,6 +76,17 @@ class SFSaleOrderCancelWizard(models.TransientModel):
|
||||
if mo_quality_checks:
|
||||
mo_quality_checks.write({'quality_state': 'cancel'})
|
||||
|
||||
# 取消制造订单的子制造订单
|
||||
child_mo_ids = self.env['mrp.production'].search([
|
||||
('origin', '=', mo.name)
|
||||
])
|
||||
|
||||
if child_mo_ids:
|
||||
# child_mo_ids |= mo.child_ids
|
||||
# for child_mo in child_mo_ids:
|
||||
for child_mo in child_mo_ids:
|
||||
child_mo.action_cancel()
|
||||
|
||||
# 取消制造订单
|
||||
mo.action_cancel()
|
||||
|
||||
@@ -274,6 +285,10 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
f = 0
|
||||
for move in picking.move_ids:
|
||||
f += 1
|
||||
flag = False
|
||||
if picking.state not in ['draft', 'cancel', 'waiting'] or (
|
||||
picking.name == '客供料入库' and picking.state not in ['cancel', 'ready']):
|
||||
flag = True
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
@@ -285,7 +300,7 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
'product_name': move.product_id.name if move.product_id else '',
|
||||
'quantity': move.product_uom_qty,
|
||||
'doc_state': map_dict.get(picking.state, picking.state),
|
||||
'cancel_reason': '已有异动' if picking.state not in ['draft', 'cancel', 'waiting'] else ''
|
||||
'cancel_reason': '已有异动' if flag else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
sequence += 1
|
||||
|
||||
Reference in New Issue
Block a user