diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 5095556d..405baf38 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -779,7 +779,8 @@ class MrpProduction(models.Model): routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search( [('name', '=', work.routing_type)]) - work.write({'date_planned_start': date_planned_start, 'date_planned_finished': date_planned_end,'duration_expected':routing_workcenter.time_cycle}) + work.write({'date_planned_start': date_planned_start, 'date_planned_finished': date_planned_end, + 'duration_expected': routing_workcenter.time_cycle}) # 修改标记已完成方法 def button_mark_done1(self): @@ -1078,27 +1079,22 @@ class MrpProduction(models.Model): productions.write({'programming_no': self.programming_no, 'is_remanufacture': True}) # productions.procurement_group_id.mrp_production_ids.move_dest_ids.write( # {'group_id': self.env['procurement.group'].search([('name', '=', sale_order.name)])}) - stock_picking = None - pc_picking = self.env['stock.picking'].search( - [('origin', '=', productions.name), ('name', 'ilike', 'WH/PC/')]) - stock_picking = pc_picking - int_picking = self.env['stock.picking'].search( - [('origin', '=', productions.name), ('name', 'ilike', 'WH/INT/')]) - stock_picking |= int_picking - for pick in stock_picking: - if pick.move_ids: - product_type_id = pick.move_ids[0].product_id.categ_id - if product_type_id.name == '坯料': - location_id = self.env['stock.location'].search([('name', '=', '坯料存货区')]) - if not location_id: - logging.info(f'没有搜索到【坯料存货区】: {location_id}') - break - if pick.picking_type_id.name == '内部调拨': - if pick.location_dest_id.product_type != product_type_id: - pick.location_dest_id = location_id.id - elif pick.picking_type_id.name == '生产发料': - if pick.location_id.product_type != product_type_id: - pick.location_id = location_id.id + stock_picking_remanufacture = self.env['stock.picking'].search([('origin', '=', productions.name)]) + for pick in stock_picking_remanufacture: + if pick.name.startswith('WH/PC/') or pick.name.startswith('WH/INT/'): + if pick.move_ids: + product_type_id = pick.move_ids[0].product_id.categ_id + if product_type_id.name == '坯料': + location_id = self.env['stock.location'].search([('name', '=', '坯料存货区')]) + if not location_id: + logging.info(f'没有搜索到【坯料存货区】: {location_id}') + break + if pick.picking_type_id.name == '内部调拨': + if pick.location_dest_id.product_type != product_type_id: + pick.location_dest_id = location_id.id + elif pick.picking_type_id.name == '生产发料': + if pick.location_id.product_type != product_type_id: + pick.location_id = location_id.id scarp_process_parameter_workorder = self.env['mrp.workorder'].search( [('surface_technics_parameters_id', '!=', False), ('production_id', '=', self.id), ('is_subcontract', '=', True)]) @@ -1111,7 +1107,6 @@ class MrpProduction(models.Model): for process_item in scarp_process_parameter_workorder: if purchase_item.product_id.categ_type == '表面工艺': if purchase_item.product_id.server_product_process_parameters_id == process_item.surface_technics_parameters_id: - print(purchase_orders.origin.find(productions.name)) if purchase_orders.origin.find(productions.name) == -1: purchase_orders.origin += ',' + productions.name if item['is_reprogramming'] is False: diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index c3842d30..8934711f 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1100,7 +1100,7 @@ class ResMrpWorkOrder(models.Model): [('barcode', 'ilike', 'VL-SPOC')]).id), ('origin', '=', self.production_id.name)]) if move_out.state != 'done': - move_out.write({'state': 'assigned'}) + move_out.write({'state': 'assigned', 'production_id': False}) self.env['stock.move.line'].create(move_out.get_move_line(self.production_id, self)) # move_out._action_assign() diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index b9483a17..9d4e3161 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -574,6 +574,7 @@ class StockPicking(models.Model): ('origin', '=', self.origin), ('picking_id', '=', self.id)]) if self.location_id == move_in.location_id and self.location_dest_id == move_in.location_dest_id: if move_out.origin == move_in.origin: + move_in.write({'production_id': False}) if move_out.picking_id.state != 'done': raise UserError( _('该入库单对应的单号为%s的出库单还未完成,不能进行验证操作!' % move_out.picking_id.name)) @@ -659,6 +660,11 @@ class ReStockMove(models.Model): return move_values def _get_new_picking_values_Res(self, item, sorted_workorders, rescode): + picking_type_id = self.mapped('picking_type_id').id + if rescode == 'WH/OCOUT/': + picking_type_id = self.env.ref('sf_manufacturing.outcontract_picking_out').id + elif rescode == 'WH/OCIN/': + picking_type_id = self.env.ref('sf_manufacturing.outcontract_picking_in').id return { 'name': self.env['stock.picking']._get_name_Res(rescode), 'origin': item.name, @@ -667,7 +673,7 @@ class ReStockMove(models.Model): 'user_id': False, 'move_type': self.mapped('group_id').move_type or 'direct', 'partner_id': sorted_workorders.supplier_id.id, - 'picking_type_id': self.mapped('picking_type_id').id, + 'picking_type_id': picking_type_id, 'location_id': self.mapped('location_id').id, 'location_dest_id': self.mapped('location_dest_id').id, 'state': 'confirmed',