From d5c65fdc6c7d9aeece4f67b9580a151c844f4bb3 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 13 Jan 2025 11:31:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=A2=E4=BE=9B=E6=96=99=E5=90=88?= =?UTF-8?q?=E5=B9=B6=EF=BC=8C=E5=9D=AF=E6=96=99=E5=88=B6=E9=80=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 8a2e0214..d3417c1f 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -1485,10 +1485,9 @@ class MrpProduction(models.Model): """ 重载创建制造订单的方法,单个制造订单,同一成品只创建一个采购组,用于后续单据的创建 """ + product_group_id = {} group_id = False - first_origin = next((obj['origin'] for obj in vals_list if 'origin' in obj), None) - if first_origin: - group_id = self.env["procurement.group"].create({'name':first_origin}).id + is_first = False for vals in vals_list: if not vals.get('name', False) or vals['name'] == _('New'): picking_type_id = vals.get('picking_type_id') @@ -1496,7 +1495,22 @@ class MrpProduction(models.Model): picking_type_id = self._get_default_picking_type_id(vals.get('company_id', self.env.company.id)) vals['picking_type_id'] = picking_type_id vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id() - if not vals.get('procurement_group_id') and group_id: + if not is_first: + is_first = True + group_id = self.env["procurement.group"].create({'name': vals.get('name')}).id + if not vals.get('procurement_group_id'): + product_id = self.env['product.product'].browse(vals['product_id']) + if product_id.product_tmpl_id.single_manufacturing: + if product_id.categ_id.name =='成品': + vals['procurement_group_id'] = group_id + continue + if product_id.id not in product_group_id.keys(): + procurement_group_vals = self._prepare_procurement_group_vals(vals) + group_id = self.env["procurement.group"].create(procurement_group_vals).id + vals['procurement_group_id'] = group_id + product_group_id[product_id.id] = group_id + else: + vals['procurement_group_id'] = product_group_id[product_id.id] vals['procurement_group_id'] = group_id return super(MrpProduction, self).create(vals_list) From 6ac3bbe2afc3a14a509a7ef99ea4a0903521aae0 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 13 Jan 2025 12:57:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A4=96=E5=8D=8F=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=8D=95=E5=85=B3=E8=81=94=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/purchase_order.py | 19 ++++++++++--------- sf_sale/models/sale_order.py | 3 ++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index e13129d5..c1f7cea8 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -93,15 +93,16 @@ class PurchaseOrder(models.Model): class PurchaseOrderLine(models.Model): _inherit = 'purchase.order.line' + part_number = fields.Char('零件图号', related='product_id.part_number', readonly=True) - related_product = fields.Many2one('product.product', compute='_compute_related_product', string='关联产品', + related_product = fields.Many2one('product.product', string='关联产品', help='经此产品工艺加工成的成品') - @api.depends('order_id.origin') - def _compute_related_product(self): - for record in self: - if record.product_id.detailed_type: - production_id = self.env['mrp.production'].search([('name', '=', record.order_id.origin)]) - record.related_product = production_id.product_id if production_id else False - else: - record.related_product = False + # @api.depends('order_id.origin') + # def _compute_related_product(self): + # for record in self: + # if record.product_id.detailed_type: + # production_id = self.env['mrp.production'].search([('name', '=', record.order_id.origin)]) + # record.related_product = production_id.product_id if production_id else False + # else: + # record.related_product = False diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index b8115520..2aa6f644 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -355,7 +355,8 @@ class RePurchaseOrder(models.Model): server_product_process.append((0, 0, { 'product_id': server_template.product_variant_id.id, 'product_qty': 1, - 'product_uom': server_template.uom_id.id + 'product_uom': server_template.uom_id.id, + 'related_product': production.product_id.id, })) # 获取服务商品最后一个供应商的采购员 purchase_user_id = server_template.seller_ids[-1].partner_id.purchase_user_id