From f3e08f5cccec9a893310e90cd1c093e4506bb97c Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 30 Dec 2024 09:43:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=9B=B6=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E7=A7=B0,=E9=9B=B6=E4=BB=B6=E5=9B=BE=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/__manifest__.py | 2 +- sf_manufacturing/models/stock.py | 75 ++++++++++++------- sf_manufacturing/views/stock_picking_view.xml | 17 ++++- sf_warehouse/models/model.py | 2 +- 4 files changed, 66 insertions(+), 30 deletions(-) diff --git a/sf_machine_connect/__manifest__.py b/sf_machine_connect/__manifest__.py index 48857914..50a157d4 100644 --- a/sf_machine_connect/__manifest__.py +++ b/sf_machine_connect/__manifest__.py @@ -25,7 +25,7 @@ # 只有它被屏蔽了 # 'views/SfWorkOrderBarcodes.xml', 'views/WorkCenterBarcodes.xml', - 'views/Stock_picking_Barcodes.xml', + # 'views/Stock_picking_Barcodes.xml', 'views/machine_monitor.xml', 'views/machine_info_present.xml', 'views/delivery_record.xml', diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 6506cc1a..6c70c245 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -588,40 +588,33 @@ class StockPicking(models.Model): address_of_delivery = fields.Char('联系地址', compute='_compute_move_ids', store=True) retrospect_ref = fields.Char('追溯参考', compute='_compute_move_ids', store=True) - + sale_order_id = fields.Many2one('sale.order', '销售单号', compute='_compute_move_ids', store=True) picking_type_sequence_code = fields.Char(related='picking_type_id.sequence_code') @api.depends('move_ids', 'move_ids.product_id') def _compute_move_ids(self): for item in self: if item.move_ids: - if item.picking_type_id.sequence_code == 'DL': - sale_name = item.move_ids[0].product_id.name.split('-')[1] - if 'S' in sale_name: - sale_id = self.env['sale.order'].sudo().search([('name', '=', sale_name)]) - item.person_of_delivery = sale_id.person_of_delivery - item.telephone_of_delivery = sale_id.telephone_of_delivery - item.address_of_delivery = sale_id.address_of_delivery + product_id = item.move_ids[0].product_id + if product_id: + sale_info = None + if product_id.categ_id.type == '坯料' and product_id.name.startswith('R-S'): + parts = product_id.name.split('-') + if len(parts) >= 3: + sale_name = parts[1] + sale_info = self.env['sale.order'].sudo().search( + [('name', '=', sale_name)]) else: - raise ValidationError('坯料名称格式错误,正确格式为[R-S???-?]!!!') - move_ids = [] - for move_id in item.move_ids: - move_ids.append(move_id.product_id.id) - boms = self.env['mrp.bom'].sudo().search([('bom_line_ids.product_id', 'in', move_ids)]) - if boms: - codes_list = [] - for bom in boms: - if bom.product_tmpl_id.default_code: - code_list = bom.product_tmpl_id.default_code.split('-') - if len(code_list) >= 4: - code = '-'.join(code_list[:4]) - if code not in codes_list: - codes_list.append(code) - else: - raise ValidationError('坯料成品的内部参考值格式错误') - item.retrospect_ref = ','.join(codes_list) - elif item.picking_type_id.sequence_code in ['INT', 'PC']: - pass + production_list = self.env['mrp.production'].sudo().search( + [('product_id', '=', product_id.id)]) + if production_list: + sale_info = production_list[0].sale_order_id + if sale_info: + item.sale_order_id = sale_info.id + if item.picking_type_id.sequence_code == 'DL': + item.person_of_delivery = sale_info.person_of_delivery + item.telephone_of_delivery = sale_info.telephone_of_delivery + item.address_of_delivery = sale_info.address_of_delivery # 设置外协出入单的名称 def _get_name_Res(self, rescode): @@ -727,6 +720,34 @@ class ReStockMove(models.Model): materiel_length = fields.Float(string='物料长度', digits=(16, 4)) materiel_width = fields.Float(string='物料宽度', digits=(16, 4)) materiel_height = fields.Float(string='物料高度', digits=(16, 4)) + part_number = fields.Char(string='零件图号', compute='_compute_part_info', store=True) + part_name = fields.Char(string='零件名称', compute='_compute_part_info', store=True) + + @api.depends('product_id') + def _compute_part_info(self): + for move in self: + if move.product_id.categ_id.type == '成品': + move.part_number = move.product_id.part_number + move.part_name = move.product_id.part_name + elif move.product_id.categ_id.type == '坯料': + if move.origin: + origin = move.origin.split(',')[0] if ',' in move.origin else move.origin + mrp_productio_info = self.env['mrp.production'].sudo().search( + [('name', '=', origin)]) + if mrp_productio_info: + move.part_number = mrp_productio_info.part_number + move.part_name = mrp_productio_info.part_name + else: + purchase_order_info = self.env['purchase.order'].sudo().search( + [('name', '=', origin)]) + if purchase_order_info: + mrp_production_ids = purchase_order_info._get_mrp_productions().ids + if mrp_production_ids: + mrp_productio_info = self.env['mrp.production'].sudo().search( + [('id', '=', mrp_production_ids[0])]) + if mrp_productio_info: + move.part_number = mrp_productio_info.part_number + move.part_name = mrp_productio_info.part_name def _get_stock_move_values_Res(self, item, picking_type_id, group_id, move_dest_ids=False): route_id = self.env.ref('sf_manufacturing.route_surface_technology_outsourcing').id diff --git a/sf_manufacturing/views/stock_picking_view.xml b/sf_manufacturing/views/stock_picking_view.xml index 30264f89..8b6fc571 100644 --- a/sf_manufacturing/views/stock_picking_view.xml +++ b/sf_manufacturing/views/stock_picking_view.xml @@ -17,6 +17,9 @@ stock.picking + + + + + + + @@ -34,6 +41,9 @@ stock.picking + + + @@ -45,8 +55,13 @@ stock.picking + + + + + - diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py index 30024239..79881920 100644 --- a/sf_warehouse/models/model.py +++ b/sf_warehouse/models/model.py @@ -1123,7 +1123,7 @@ class SfPickingType(models.Model): if not self.env.user.has_group('base.group_system'): action['context']['create'] = False if self.sequence_code in ['DL', 'INT', 'PC']: - action['context']['search_default_retrospect_ref'] = 1 + action['context']['search_default_retrospect'] = 1 return action