表面工艺采购单确认订单进行限制

This commit is contained in:
liaodanlong
2024-12-31 17:08:38 +08:00
parent 37476bcc88
commit 701decb38f
3 changed files with 19 additions and 123 deletions

View File

@@ -391,6 +391,23 @@ class RePurchaseOrder(models.Model):
production = self.env['mrp.production'].search([('name', '=', production_name)])
for workorder in production.workorder_ids.filtered(
lambda wd: wd.routing_type == '表面工艺' and wd.state == 'waiting' and line.product_id.server_product_process_parameters_id == wd.surface_technics_parameters_id):
work_ids = workorder.production_id.workorder_ids.filtered(
lambda wk: wk.state not in ['done', 'rework', 'cancel'])
min_sequence_wk = min(work_ids, key=lambda wk: wk.sequence)
artificial_offline = (
workorder.production_id.production_type == '人工线下加工' and workorder.production_id.schedule_state != '已排')
auto_production = (
workorder.production_id.production_type == '自动化产线加工' and workorder.production_id.schedule_state != '已编程')
if workorder.sequence == min_sequence_wk.sequence:
if artificial_offline or auto_production:
raise UserError('等待组件')
else:
sorted_work_ids = work_ids.sorted(key=lambda w: w.sequence)
previous_workorder = self.env['mrp.workorder'].search([('sequence', '<', workorder.sequence),
('production_id', '=', workorder.production_id.id),
('state', '=', 'done')], order='sequence desc', limit=1)
if not previous_workorder:
raise UserError('等待组件')
workorder.state = 'ready'
return result
@@ -423,6 +440,7 @@ class PurchaseOrderLine(models.Model):
part_name = fields.Char('零件名称', related='product_id.part_name', readonly=True)
# part_number = fields.Char('零件图号',related='product_id.part_number', readonly=True)
class ResPartnerToSale(models.Model):
_inherit = 'res.partner'