Accept Merge Request #1699: (feature/part_number -> develop)

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

Created By: @廖丹龙
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @廖丹龙
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1699
This commit is contained in:
廖丹龙
2025-01-02 09:08:27 +08:00
committed by Coding
3 changed files with 19 additions and 123 deletions

View File

@@ -395,6 +395,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
@@ -427,6 +444,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'