优化工艺设计显示
This commit is contained in:
@@ -251,6 +251,7 @@ class MrpProduction(models.Model):
|
|||||||
remanufacture_count = fields.Integer("重新制造订单数量", compute='_compute_remanufacture_production_ids')
|
remanufacture_count = fields.Integer("重新制造订单数量", compute='_compute_remanufacture_production_ids')
|
||||||
remanufacture_production_id = fields.Many2one('mrp.production', string='')
|
remanufacture_production_id = fields.Many2one('mrp.production', string='')
|
||||||
technology_design_ids = fields.One2many('sf.technology.design', 'production_id', string='工艺设计')
|
technology_design_ids = fields.One2many('sf.technology.design', 'production_id', string='工艺设计')
|
||||||
|
is_adjust = fields.Boolean('是否退回调整', default=False)
|
||||||
|
|
||||||
@api.depends('remanufacture_production_id')
|
@api.depends('remanufacture_production_id')
|
||||||
def _compute_remanufacture_production_ids(self):
|
def _compute_remanufacture_production_ids(self):
|
||||||
@@ -312,6 +313,9 @@ class MrpProduction(models.Model):
|
|||||||
production.state == 'to_close' or production.state == 'progress') and production.schedule_state == '未排':
|
production.state == 'to_close' or production.state == 'progress') and production.schedule_state == '未排':
|
||||||
if not production.workorder_ids:
|
if not production.workorder_ids:
|
||||||
production.state = 'technology_to_confirmed'
|
production.state = 'technology_to_confirmed'
|
||||||
|
else:
|
||||||
|
if production.is_adjust == True:
|
||||||
|
production.state = 'technology_to_confirmed'
|
||||||
else:
|
else:
|
||||||
production.state = 'confirmed'
|
production.state = 'confirmed'
|
||||||
elif production.state == 'pending_cam' and production.schedule_state == '未排':
|
elif production.state == 'pending_cam' and production.schedule_state == '未排':
|
||||||
@@ -818,9 +822,16 @@ class MrpProduction(models.Model):
|
|||||||
self._reset_work_order_sequence1(k)
|
self._reset_work_order_sequence1(k)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
#需对不连续工单对应的采购单和外协出入库单做处理
|
# 需对不连续工单对应的采购单和外协出入库单做处理
|
||||||
def _reset_subcontract_pick_purchase(self):
|
def _reset_subcontract_pick_purchase(self):
|
||||||
for item in self:
|
production_all = self.sorted(lambda x: x.id)
|
||||||
|
product_id_to_production_names = {}
|
||||||
|
grouped_product_ids = {k: list(g) for k, g in
|
||||||
|
groupby(production_all, key=lambda x: x.product_id.id)}
|
||||||
|
for product_id, pd in grouped_product_ids.items():
|
||||||
|
product_id_to_production_names[product_id] = [p.name for p in pd]
|
||||||
|
for item in production_all:
|
||||||
|
production_process = product_id_to_production_names.get(item.product_id.id)
|
||||||
workorder_sf = item.workorder_ids.filtered(lambda sf: sf.routing_type == '表面工艺')
|
workorder_sf = item.workorder_ids.filtered(lambda sf: sf.routing_type == '表面工艺')
|
||||||
for i, workorder in enumerate(workorder_sf):
|
for i, workorder in enumerate(workorder_sf):
|
||||||
if i == 0:
|
if i == 0:
|
||||||
@@ -828,6 +839,18 @@ class MrpProduction(models.Model):
|
|||||||
elif workorder.sequence != workorder_sf[i - 1].sequence + 1:
|
elif workorder.sequence != workorder_sf[i - 1].sequence + 1:
|
||||||
# workorder.picking_ids.move_ids = False
|
# workorder.picking_ids.move_ids = False
|
||||||
workorder.picking_ids = False
|
workorder.picking_ids = False
|
||||||
|
purchase_order = self.env['purchase.order'].search(
|
||||||
|
[('state', '=', 'draft'), ('origin', '=', ','.join(production_process)),
|
||||||
|
('purchase_type', '=', 'consignment')])
|
||||||
|
for line in purchase_order.order_line:
|
||||||
|
server_template = self.env['product.template'].search(
|
||||||
|
[('server_product_process_parameters_id', '=', workorder.surface_technics_parameters_id.id),
|
||||||
|
('detailed_type', '=', 'service')])
|
||||||
|
purchase_order_line = self.env['purchase.order.line'].search(
|
||||||
|
[('product_id', '=', server_template.product_variant_id.id), ('id', '=', line.id),
|
||||||
|
('product_qty', '=', len(production_process))], limit=1, order='id desc')
|
||||||
|
if purchase_order_line:
|
||||||
|
line.unlink()
|
||||||
|
|
||||||
def _reset_work_order_sequence(self):
|
def _reset_work_order_sequence(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -353,7 +353,7 @@
|
|||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//sheet//notebook//page[@name='components']" position="before">
|
<xpath expr="//sheet//notebook//page[@name='components']" position="before">
|
||||||
<page string="工艺设计">
|
<page string="工艺设计" attrs="{'invisible': [('state', '!=', 'technology_to_confirmed')]}">
|
||||||
<field name="technology_design_ids" widget="one2many">
|
<field name="technology_design_ids" widget="one2many">
|
||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
<field name="sequence" widget="handle"/>
|
<field name="sequence" widget="handle"/>
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
productions._reset_work_order_sequence()
|
productions._reset_work_order_sequence()
|
||||||
productions._reset_subcontract_pick_purchase()
|
productions._reset_subcontract_pick_purchase()
|
||||||
productions.get_subcontract_pick_purchase()
|
productions.get_subcontract_pick_purchase()
|
||||||
|
productions.is_adjust = True
|
||||||
for item in productions:
|
for item in productions:
|
||||||
workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||||
key=lambda a: a.sequence)
|
key=lambda a: a.sequence)
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class ProductionTechnologyWizard(models.TransientModel):
|
|||||||
# # if special:
|
# # if special:
|
||||||
productions._create_workorder(False)
|
productions._create_workorder(False)
|
||||||
productions.get_subcontract_pick_purchase()
|
productions.get_subcontract_pick_purchase()
|
||||||
|
productions.is_adjust = False
|
||||||
for item in productions:
|
for item in productions:
|
||||||
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||||
key=lambda a: a.sequence)
|
key=lambda a: a.sequence)
|
||||||
|
|||||||
Reference in New Issue
Block a user