完善下游单据问题
This commit is contained in:
@@ -192,5 +192,5 @@ access_sf_programming_reason,sf_programming_reason,model_sf_programming_reason,b
|
||||
access_sf_programming_record,sf_programming_record,model_sf_programming_record,base.group_user,1,1,1,0
|
||||
access_sf_work_individuation_page,sf_work_individuation_page,model_sf_work_individuation_page,sf_base.group_sf_mrp_user,1,1,1,0
|
||||
access_sf_work_individuation_page_group_plan_dispatch,sf_work_individuation_page_group_plan_dispatch,model_sf_work_individuation_page,sf_base.group_plan_dispatch,1,1,0,0
|
||||
access_sf_sale_order_cancel_wizard,sf_sale_order_cancel_wizard,model_sf_sale_order_cancel_wizard,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_sf_sale_order_cancel_line,sf_sale_order_cancel_line,model_sf_sale_order_cancel_line,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_sf_sale_order_cancel_wizard,sf_sale_order_cancel_wizard,model_sf_sale_order_cancel_wizard,sf_base.group_sf_order_user,1,0,1,0
|
||||
access_sf_sale_order_cancel_line,sf_sale_order_cancel_line,model_sf_sale_order_cancel_line,sf_base.group_sf_order_user,1,0,1,0
|
||||
|
@@ -209,29 +209,169 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
lines.append(self.create(vals))
|
||||
sequence += 1
|
||||
|
||||
# # 成品质检单
|
||||
# fin_quality_checks = self.env['quality.check'].search([
|
||||
# ('picking_id', '=', picking.id)
|
||||
# ])
|
||||
# if fin_quality_checks:
|
||||
# b1 = 0
|
||||
# for fin_qc in fin_quality_checks:
|
||||
# b1 += 1
|
||||
# vals = {
|
||||
# 'wizard_id': wizard_id,
|
||||
# 'sequence': sequence,
|
||||
# 'category': '制造',
|
||||
# 'doc_name': '质检单',
|
||||
# 'operation_type': '',
|
||||
# 'doc_number': fin_qc.name,
|
||||
# 'line_number': b1,
|
||||
# 'product_name': f'[{fin_qc.product_id.default_code}] {fin_qc.product_id.name}',
|
||||
# 'quantity': 1,
|
||||
# 'doc_state': map_dict.get(fin_qc.quality_state, fin_qc.quality_state),
|
||||
# 'cancel_reason': '已有异动' if fin_qc.quality_state not in ['none', 'cancel', 'waiting'] else ''
|
||||
# }
|
||||
# lines.append(self.create(vals))
|
||||
|
||||
# 检查所有的质检单
|
||||
quality_checks = self.env['quality.check'].search([
|
||||
('product_id.name', 'like', f'%{order.name}%')])
|
||||
if quality_checks:
|
||||
b1 = 0
|
||||
for quality_check in quality_checks:
|
||||
b1 += 1
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
'category': '质量',
|
||||
'doc_name': '质检单',
|
||||
'operation_type': '',
|
||||
'doc_number': f'{quality_check.name}-{quality_check.title}',
|
||||
'line_number': 1,
|
||||
'product_name': f'[{quality_check.product_id.default_code}] {quality_check.product_id.name}' if quality_check.product_id.default_code else quality_check.product_id.name,
|
||||
'quantity': 1,
|
||||
'doc_state': map_dict.get(quality_check.quality_state, quality_check.quality_state),
|
||||
'cancel_reason': '已有异动' if quality_check.quality_state not in ['none', 'cancel', 'waiting'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
|
||||
# 检查组件的制造单
|
||||
# component_mos = self.env['mrp.production'].search([
|
||||
# ('origin', '=', mo.name)])
|
||||
component_mos = self.env['mrp.production'].search([
|
||||
('product_id.name', 'like', f'%R-{order.name}%')])
|
||||
h = 0
|
||||
if component_mos:
|
||||
for comp_mo in component_mos:
|
||||
h += 1
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
'category': '制造',
|
||||
'doc_name': '组件制造单',
|
||||
'operation_type': '',
|
||||
'doc_number': comp_mo.name,
|
||||
'line_number': h,
|
||||
'product_name': f'{comp_mo.product_id.name}',
|
||||
'quantity': comp_mo.product_qty,
|
||||
'doc_state': map_dict.get(comp_mo.state, comp_mo.state),
|
||||
'cancel_reason': '已有异动' if comp_mo.state not in ['technology_to_confirmed',
|
||||
'cancel'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
sequence += 1
|
||||
|
||||
for pinking_id in comp_mo.picking_ids:
|
||||
y = 0
|
||||
for move in pinking_id.move_ids:
|
||||
y += 1
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
'category': '子制造调拨',
|
||||
'doc_name': '库存移动',
|
||||
'doc_number': f'{comp_mo.name}-{pinking_id.name}',
|
||||
'line_number': y,
|
||||
'operation_type': pinking_id.picking_type_id.name,
|
||||
'product_name': move.product_id.name if move.product_id else '',
|
||||
'quantity': move.product_uom_qty,
|
||||
'doc_state': map_dict.get(pinking_id.state, pinking_id.state),
|
||||
'cancel_reason': '已有异动' if pinking_id.state not in ['cancel', 'waiting',
|
||||
'assigned'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
|
||||
# 检查销售订单直接关联的采购单
|
||||
purchase_orders = self.env['purchase.order'].search([
|
||||
('origin', '=', order.name)
|
||||
('origin', 'like', f'%{order.name}%')
|
||||
])
|
||||
if purchase_orders:
|
||||
c = 0
|
||||
for po in purchase_orders:
|
||||
c += 1
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
'category': '采购',
|
||||
'doc_name': '询价单',
|
||||
'operation_type': '',
|
||||
'doc_number': po.name,
|
||||
'line_number': c,
|
||||
'product_name': po.order_line[0].product_id.name if po.order_line else '',
|
||||
'quantity': po.order_line[0].product_qty if po.order_line else 0,
|
||||
'doc_state': map_dict.get(po.state, po.state),
|
||||
'cancel_reason': '已有异动' if po.state not in ['draft', 'cancel'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
sequence += 1
|
||||
for order_line in po.order_line:
|
||||
c += 1
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
'category': '采购',
|
||||
'doc_name': '询价单',
|
||||
'operation_type': '',
|
||||
'doc_number': po.name,
|
||||
'line_number': c,
|
||||
'product_name': f'[{order_line.product_id.default_code}] {order_line.product_id.name}',
|
||||
'quantity': order_line.product_qty if order_line else 0,
|
||||
'doc_state': map_dict.get(po.state, po.state),
|
||||
'cancel_reason': '已有异动' if po.state not in ['draft', 'cancel'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
sequence += 1
|
||||
|
||||
# 客供料的入库单
|
||||
for pod in purchase_orders:
|
||||
pkds = self.env['stock.picking'].search([
|
||||
('origin', '=', pod.name)
|
||||
])
|
||||
if pkds:
|
||||
for pkd in pkds:
|
||||
x3 = 0
|
||||
for move in pkd.move_ids:
|
||||
x3 += 1
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
'category': '库存',
|
||||
'doc_name': '库存移动',
|
||||
'doc_number': pkd.name,
|
||||
'line_number': x3,
|
||||
'operation_type': pkd.picking_type_id.name,
|
||||
'product_name': f'[{move.product_id.default_code}] {move.product_id.name}',
|
||||
'quantity': move.product_uom_qty,
|
||||
'doc_state': map_dict.get(pkd.state, pkd.state),
|
||||
'cancel_reason': '已有异动' if pkd.state not in ['waiting', 'cancel', 'confirmed'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
|
||||
#
|
||||
for child_pkd in self.env['stock.picking'].search([
|
||||
('origin', '=', pkd.name)
|
||||
]):
|
||||
x4 = 0
|
||||
for child_move in child_pkd.move_ids:
|
||||
x4 += 1
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
'category': '库存',
|
||||
'doc_name': '库存移动',
|
||||
'doc_number': child_pkd.name,
|
||||
'line_number': x4,
|
||||
'operation_type': child_pkd.picking_type_id.name,
|
||||
'product_name': child_move.product_id.name if child_move.product_id else '',
|
||||
'quantity': child_move.product_uom_qty,
|
||||
'doc_state': map_dict.get(child_pkd.state, child_pkd.state),
|
||||
'cancel_reason': '已有异动' if child_pkd.state not in ['waiting',
|
||||
'cancel', 'confirmed'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
|
||||
# 检查制造订单
|
||||
manufacturing_orders = self.env['mrp.production'].search([
|
||||
@@ -262,7 +402,7 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
|
||||
# 检查制造订单关联的采购单
|
||||
purchase_orders = self.env['purchase.order'].search([
|
||||
('origin', '=', mo.name)
|
||||
('origin', 'like', f'%{mo.name}%')
|
||||
])
|
||||
if purchase_orders:
|
||||
e = 0
|
||||
@@ -323,7 +463,7 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
'category': '坯料外协',
|
||||
'doc_name': '库存移动',
|
||||
'doc_number': child_pkd.name,
|
||||
'line_number': x1,
|
||||
'line_number': x2,
|
||||
'operation_type': child_pkd.picking_type_id.name,
|
||||
'product_name': child_move.product_id.name if child_move.product_id else '',
|
||||
'quantity': child_move.product_uom_qty,
|
||||
@@ -404,95 +544,52 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
|
||||
# 检查制造订单组件的采购单和制造单
|
||||
for move in mo.move_raw_ids:
|
||||
# # 检查组件的采购单
|
||||
# component_pos = self.env['purchase.order'].search([
|
||||
# ('origin', '=', mo.name),
|
||||
# ('order_line.product_id', '=', move.product_id.id)
|
||||
# ])
|
||||
# for po in component_pos:
|
||||
# vals = {
|
||||
# 'wizard_id': wizard_id,
|
||||
# 'sequence': sequence,
|
||||
# 'category': '制造',
|
||||
# 'doc_name': '组件采购单',
|
||||
# 'operation_type': '组件采购',
|
||||
# 'doc_number': po.name,
|
||||
# 'product_name': move.product_id.name,
|
||||
# 'quantity': po.order_line[0].product_qty if po.order_line else 0,
|
||||
# 'doc_state': po.state,
|
||||
# 'cancel_reason': '已有异动' if po.state not in ['draft', 'cancel'] else ''
|
||||
# }
|
||||
# lines.append(self.create(vals))
|
||||
# sequence += 1
|
||||
# # 检查制造订单组件的采购单和制造单
|
||||
# for move in mo.move_raw_ids:
|
||||
# # 检查组件的采购单
|
||||
# component_pos = self.env['purchase.order'].search([
|
||||
# ('origin', '=', mo.name),
|
||||
# ('order_line.product_id', '=', move.product_id.id)
|
||||
# ])
|
||||
# for po in component_pos:
|
||||
# vals = {
|
||||
# 'wizard_id': wizard_id,
|
||||
# 'sequence': sequence,
|
||||
# 'category': '制造',
|
||||
# 'doc_name': '组件采购单',
|
||||
# 'operation_type': '组件采购',
|
||||
# 'doc_number': po.name,
|
||||
# 'product_name': move.product_id.name,
|
||||
# 'quantity': po.order_line[0].product_qty if po.order_line else 0,
|
||||
# 'doc_state': po.state,
|
||||
# 'cancel_reason': '已有异动' if po.state not in ['draft', 'cancel'] else ''
|
||||
# }
|
||||
# lines.append(self.create(vals))
|
||||
# sequence += 1
|
||||
|
||||
# 检查组件的制造单
|
||||
component_mos = self.env['mrp.production'].search([
|
||||
('origin', '=', mo.name)])
|
||||
h = 0
|
||||
if component_mos:
|
||||
for comp_mo in component_mos:
|
||||
h += 1
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
'category': '制造',
|
||||
'doc_name': '组件制造单',
|
||||
'operation_type': '',
|
||||
'doc_number': comp_mo.name,
|
||||
'line_number': h,
|
||||
'product_name': move.product_id.name,
|
||||
'quantity': comp_mo.product_qty,
|
||||
'doc_state': map_dict.get(comp_mo.state, comp_mo.state),
|
||||
'cancel_reason': '已有异动' if comp_mo.state not in ['technology_to_confirmed',
|
||||
'cancel'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
sequence += 1
|
||||
|
||||
for pinking_id in comp_mo.picking_ids:
|
||||
y = 0
|
||||
for move in pinking_id.move_ids:
|
||||
y += 1
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
'category': '子制造调拨',
|
||||
'doc_name': '库存移动',
|
||||
'doc_number': f'{comp_mo.name}-{pinking_id.name}',
|
||||
'line_number': y,
|
||||
'operation_type': pinking_id.picking_type_id.name,
|
||||
'product_name': move.product_id.name if move.product_id else '',
|
||||
'quantity': move.product_uom_qty,
|
||||
'doc_state': map_dict.get(pinking_id.state, pinking_id.state),
|
||||
'cancel_reason': '已有异动' if pinking_id.state not in ['cancel', 'waiting'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
|
||||
# 检查制造订单的质检单
|
||||
quality_checks = self.env['quality.check'].search([
|
||||
('production_id', '=', mo.id)
|
||||
])
|
||||
if quality_checks:
|
||||
i = 0
|
||||
for check in quality_checks:
|
||||
i += 1
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
'category': '制造',
|
||||
'doc_name': '质检单',
|
||||
'operation_type': '',
|
||||
'doc_number': check.name,
|
||||
'line_number': i,
|
||||
'product_name': f'[{check.product_id.default_code}] {check.product_id.name}',
|
||||
'quantity': 1,
|
||||
'doc_state': map_dict.get(check.quality_state, check.quality_state),
|
||||
'cancel_reason': '已有异动' if check.quality_state not in ['none', 'cancel', 'waiting'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
sequence += 1
|
||||
# # 检查制造订单的质检单
|
||||
# quality_checks = self.env['quality.check'].search([
|
||||
# ('production_id', '=', mo.id)
|
||||
# ])
|
||||
# if quality_checks:
|
||||
# i = 0
|
||||
# for check in quality_checks:
|
||||
# i += 1
|
||||
# vals = {
|
||||
# 'wizard_id': wizard_id,
|
||||
# 'sequence': sequence,
|
||||
# 'category': '制造',
|
||||
# 'doc_name': '质检单',
|
||||
# 'operation_type': '',
|
||||
# 'doc_number': check.name,
|
||||
# 'line_number': i,
|
||||
# 'product_name': f'[{check.product_id.default_code}] {check.product_id.name}',
|
||||
# 'quantity': 1,
|
||||
# 'doc_state': map_dict.get(check.quality_state, check.quality_state),
|
||||
# 'cancel_reason': '已有异动' if check.quality_state not in ['none', 'cancel', 'waiting'] else ''
|
||||
# }
|
||||
# lines.append(self.create(vals))
|
||||
# sequence += 1
|
||||
|
||||
# 检查制造订单的编程单
|
||||
cloud_programming = mo._cron_get_programming_state()
|
||||
|
||||
@@ -39,4 +39,31 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_sf_sale_order_cancel_line" model="ir.ui.view">
|
||||
<field name="name">sf.sale.order.cancel.line.form</field>
|
||||
<field name="model">sf.sale.order.cancel.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="下游单据明细">
|
||||
<group>
|
||||
<group>
|
||||
<field name="category"/>
|
||||
<field name="doc_name"/>
|
||||
<field name="operation_type"/>
|
||||
<field name="quantity_str"/>
|
||||
<field name="cancel_reason"/>
|
||||
|
||||
</group>
|
||||
<group>
|
||||
<field name="line_number"/>
|
||||
<field name="doc_number"/>
|
||||
<field name="product_name"/>
|
||||
<field name="doc_state"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user