优化制造订单报废

This commit is contained in:
jinling.yang
2024-11-22 17:51:40 +08:00
parent 70f8aadd66
commit 33b9c48e87
5 changed files with 56 additions and 54 deletions

View File

@@ -275,19 +275,19 @@ class ResMrpWorkOrder(models.Model):
production_programming = self.env['mrp.production'].search(domain, order='name asc')
production_list = [production.name for production in production_programming]
production_no_remanufacture = production_programming.filtered(lambda a: a.is_remanufacture is False)
technology_design = self.env['sf.technology.design'].search(
[('process_parameters_id', '=', order.surface_technics_parameters_id.id),
('production_id', '=', order.production_id.id)])
if technology_design.is_auto is False:
domain = [('origin', '=', order.production_id.name)]
else:
domain = [('origin', '=', ','.join(production_list))]
# technology_design = self.env['sf.technology.design'].search(
# [('process_parameters_id', '=', order.surface_technics_parameters_id.id),
# ('production_id', '=', order.production_id.id)])
# if technology_design.is_auto is False:
# domain = [('origin', '=', order.production_id.name)]
# else:
domain = [('purchase_type', '=', 'consignment'),('origin', '=', ','.join(production_list))]
purchase = self.env['purchase.order'].search(domain)
if not purchase:
order.surface_technics_purchase_count = 0
for line in purchase.order_line:
if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id:
if (line.product_qty == len(production_no_remanufacture)) or technology_design.is_auto is False:
if line.product_qty == len(production_no_remanufacture):
order.surface_technics_purchase_count = len(purchase)
else:
order.surface_technics_purchase_count = 0
@@ -301,13 +301,13 @@ class ResMrpWorkOrder(models.Model):
domain = [('origin', '=', self.production_id.origin)]
production_programming = self.env['mrp.production'].search(domain, order='name asc')
production_list = [production.name for production in production_programming]
technology_design = self.env['sf.technology.design'].search(
[('process_parameters_id', '=', self.surface_technics_parameters_id.id),
('production_id', '=', self.production_id.id)])
if technology_design.is_auto is False:
domain = [('origin', '=', self.production_id.name)]
else:
domain = [('origin', '=', ','.join(production_list))]
# technology_design = self.env['sf.technology.design'].search(
# [('process_parameters_id', '=', self.surface_technics_parameters_id.id),
# ('production_id', '=', self.production_id.id)])
# if technology_design.is_auto is False:
# domain = [('origin', '=', self.production_id.name)]
# else:
domain = [('origin', '=', ','.join(production_list)), ('purchase_type', '=', 'consignment')]
purchase_orders = self.env['purchase.order'].search(domain)
result = {
"type": "ir.actions.act_window",
@@ -1011,7 +1011,8 @@ class ResMrpWorkOrder(models.Model):
return workorders_values_str
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state',
'production_id.tool_state', 'production_id.schedule_state', 'sequence')
'production_id.tool_state', 'production_id.schedule_state', 'sequence',
'production_id.programming_state')
def _compute_state(self):
# super()._compute_state()
for workorder in self:
@@ -1077,7 +1078,8 @@ class ResMrpWorkOrder(models.Model):
# ================= 如果制造订单刀具状态为[无效刀、缺刀] 或者 制造订单状态为[返工]==========================
if (workorder.production_id.tool_state in ['1', '2'] or workorder.production_id.state == 'rework'
or workorder.production_id.schedule_state != '已排'
or workorder.production_id.reservation_state != 'assigned'
or len(
workorder.production_id.picking_ids.filtered(lambda w: w.state not in ['done', 'cancel'])) != 0
or workorder.production_id.workorder_ids.filtered(
lambda wk: wk.sequence == workorder.sequence - 1).test_results in ['报废', '返工']):
if workorder.state != 'waiting':