From 5b75e5423a3c4a779ffcc6c6b1c510a3f64f2c89 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 18 Oct 2022 18:36:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=94=9F=E6=88=90bom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/__manifest__.py | 2 +- sf_base/views/menu_view.xml | 14 ++--- sf_bpm_api/controllers/controllers.py | 2 + sf_bpm_api/models/product_template.py | 60 ++++++++++++++++++++-- sf_bpm_api/models/sale_order.py | 2 +- sf_bpm_api/views/product_template_view.xml | 51 ++++++++++++++++-- 6 files changed, 113 insertions(+), 18 deletions(-) diff --git a/sf_base/__manifest__.py b/sf_base/__manifest__.py index 4a493cd2..77165cde 100644 --- a/sf_base/__manifest__.py +++ b/sf_base/__manifest__.py @@ -10,7 +10,7 @@ """, 'category': 'YZ', 'website': 'https://www.sf.jikimo.com', - 'depends': ['account', 'base', 'mrp', 'sf_bpm_api'], + 'depends': ['account', 'base', 'mrp'], 'data': [ 'security/group_security.xml', 'security/ir.model.access.csv', diff --git a/sf_base/views/menu_view.xml b/sf_base/views/menu_view.xml index e9a5876a..66550d05 100644 --- a/sf_base/views/menu_view.xml +++ b/sf_base/views/menu_view.xml @@ -91,13 +91,13 @@ sequence="1" action="mrs_processing_technology"/> - + + + + + + + ', product.model_long), ('embryo_width', '>', product.model_width), + ('embryo_height', '>', product.model_height)], + limit=1, + order="volume desc" + ) + vals = { + 'bom_id': self.id, + 'product_id': embryo.id, + 'product_qty': 1, + 'product_uom_id': 1 + } + return self.env['mrp.bom.line'].create(vals) diff --git a/sf_bpm_api/models/sale_order.py b/sf_bpm_api/models/sale_order.py index dd2b2ac1..1618a4e3 100644 --- a/sf_bpm_api/models/sale_order.py +++ b/sf_bpm_api/models/sale_order.py @@ -27,7 +27,7 @@ class ReSaleOrder(models.Model): vals = { 'order_id': self.id, 'product_id': product.id, - 'name': '%s/%s/%s/%s/%s' % (item['model_long'], item['model_width'], item['model_height'], item['model_volume'], product.materials_id.name), + 'name': '%s/%s/%s/%s/%s' % (item['model_long'], item['model_width'], item['model_height'], item['model_volume'], product.model_materials_id.name), 'price_unit': item['price'], 'product_uom_qty': item['number'] } diff --git a/sf_bpm_api/views/product_template_view.xml b/sf_bpm_api/views/product_template_view.xml index d68f2039..406330e3 100644 --- a/sf_bpm_api/views/product_template_view.xml +++ b/sf_bpm_api/views/product_template_view.xml @@ -10,18 +10,59 @@ - - - - + + + + - + + + + + + + + + + + product.category.form.inherit.sf + product.category + + + + + From c2bf0b09a9bb08bcb8b357c45a7906643fe1b209 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 19 Oct 2022 11:16:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=83=9A=E6=96=99?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_bpm_api/controllers/controllers.py | 4 ++-- sf_bpm_api/models/product_template.py | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sf_bpm_api/controllers/controllers.py b/sf_bpm_api/controllers/controllers.py index 05dbb244..aeec79b6 100644 --- a/sf_bpm_api/controllers/controllers.py +++ b/sf_bpm_api/controllers/controllers.py @@ -30,8 +30,8 @@ class Sf_Bf_Connect(http.Controller): product = request.env['product.template'].sudo().product_create(product_id, item, order_id, ret['order_number'], i) order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item) - bom = request.env['mrp.bom'].sudo().bom_create(product) - bom.sudo().bom_create_Line(product) + bom = request.env['mrp.bom'].with_user(request.env.ref("base.user_admin")).bom_create(product) + bom.with_user(request.env.ref("base.user_admin")).bom_create_Line(product) i += 1 res['factory_order_no'] = order_id.name return json.JSONEncoder().encode(res) diff --git a/sf_bpm_api/models/product_template.py b/sf_bpm_api/models/product_template.py index 0ea5a772..06a691b3 100644 --- a/sf_bpm_api/models/product_template.py +++ b/sf_bpm_api/models/product_template.py @@ -54,7 +54,7 @@ class ResMrpBom(models.Model): # 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom def bom_create(self, product): - bom_id = self.env['mrp.bom'].sudo().create({ + bom_id = self.env['mrp.bom'].create({ 'product_tmpl_id': product.product_tmpl_id.id, 'type': 'normal', 'product_qty': 1, @@ -68,16 +68,18 @@ class ResMrpBom(models.Model): # 三、胚料的长宽高均要大于模型的长宽高; # 四、如果匹配成功多个胚料,则选取体积最小的胚料; def bom_create_Line(self, product): - embryo = self.env['product.template'].sudo().search( + embryo = self.env['product.product'].search( [('categ_id.is_embryo', '=', True), ('embryo_materials_type_id', '=', product.model_materials_type_id.id), ('embryo_long', '>', product.model_long), ('embryo_width', '>', product.model_width), - ('embryo_height', '>', product.model_height)], + ('embryo_height', '>', product.model_height) + ], limit=1, - order="volume desc" + order='volume desc' ) vals = { 'bom_id': self.id, 'product_id': embryo.id, + 'product_tmpl_id': embryo.product_tmpl_id.id, 'product_qty': 1, 'product_uom_id': 1 }