diff --git a/jikimo_sale_multiple_supply_methods/controllers/main.py b/jikimo_sale_multiple_supply_methods/controllers/main.py index 9127f80e..b5a25749 100644 --- a/jikimo_sale_multiple_supply_methods/controllers/main.py +++ b/jikimo_sale_multiple_supply_methods/controllers/main.py @@ -34,6 +34,9 @@ class JikimoSaleRoutePicking(Sf_Bf_Connect): if kw.get('logistics_way'): order_id.logistics_way = kw['logistics_way'] for item in bfm_process_order_list: + if item.get('embryo_redundancy_id'): + item['embryo_redundancy'] = request.env['sf.embryo.redundancy'].sudo().search([('code', '=', item['embryo_redundancy_id'])], limit=1) + item['embryo_redundancy_id'] = item['embryo_redundancy'].id product = request.env['product.template'].sudo().product_create(product_id, item, order_id, kw['order_number'], i) order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item) diff --git a/jikimo_sale_multiple_supply_methods/models/product_template.py b/jikimo_sale_multiple_supply_methods/models/product_template.py index fd9de9f9..c7dfa1ab 100644 --- a/jikimo_sale_multiple_supply_methods/models/product_template.py +++ b/jikimo_sale_multiple_supply_methods/models/product_template.py @@ -8,7 +8,7 @@ class ProductTemplate(models.Model): def product_create(self, product_id, item, order_id, order_number, i): product_id = super(ProductTemplate, self).product_create(product_id, item, order_id, order_number, i) - product_id.product_tmpl_id.is_customer_provided = item['is_incoming_material'] + product_id.product_tmpl_id.is_customer_provided = True if item['embryo_redundancy_id'] else False return product_id diff --git a/jikimo_sale_multiple_supply_methods/models/sale_order.py b/jikimo_sale_multiple_supply_methods/models/sale_order.py index 27dd1757..a1920a50 100644 --- a/jikimo_sale_multiple_supply_methods/models/sale_order.py +++ b/jikimo_sale_multiple_supply_methods/models/sale_order.py @@ -54,6 +54,7 @@ class SaleOrder(models.Model): 'model_width': product.width, 'model_height': product.height, 'price': product.list_price, + 'embryo_redundancy_id': line.embryo_redundancy_id, } # 获取成品名结尾-n的n product_seria = int(product.name.split('-')[-1]) @@ -66,7 +67,7 @@ class SaleOrder(models.Model): bom.with_user(self.env.ref("base.user_admin")).bom_create_line_has(bom_data) else: # 当成品上带有客供料选项时,生成坯料时选择“客供料”路线 - if line.is_incoming_material: + if line.embryo_redundancy_id: # 将成品模板的内容复制到成品上 customer_provided_embryo = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_embryo_customer_provided').sudo() # 创建坯料,客供料的批量不需要创建bom diff --git a/jikimo_sale_multiple_supply_methods/views/sale_order_views.xml b/jikimo_sale_multiple_supply_methods/views/sale_order_views.xml index 2ea9a835..1cf6eb3f 100644 --- a/jikimo_sale_multiple_supply_methods/views/sale_order_views.xml +++ b/jikimo_sale_multiple_supply_methods/views/sale_order_views.xml @@ -59,6 +59,7 @@ + {'search_default_draft': 1} diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index 34605cca..8dd4a023 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -251,3 +251,6 @@ access_sf_cutting_tool_type_group_plan_dispatch,sf_cutting_tool_type_group_plan_ access_sf_machining_accuracy,sf_machining_accuracy,model_sf_machining_accuracy,base.group_user,1,0,0,0 access_sf_machining_accuracy_admin,sf_machining_accuracy_admin,model_sf_machining_accuracy,base.group_system,1,0,0,0 + +access_sf_embryo_redundancy,sf_embryo_redundancy,model_sf_embryo_redundancy,base.group_user,1,0,0,0 +access_sf_embryo_redundancy_admin,sf_embryo_redundancy_admin,model_sf_embryo_redundancy,base.group_system,1,0,0,0 diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index baf0c1b5..3993a138 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -850,14 +850,19 @@ class ResProductMo(models.Model): copy_product_id.product_tmpl_id.active = True model_type = self.env['sf.model.type'].search([], limit=1) attachment = self.attachment_create(item['model_name'], item['model_data']) + # 获取坯料冗余配置 + if not item.get('embryo_redundancy'): + embryo_redundancy_id = self.env['sf.embryo.redundancy'].search([('name', '=', '粗坯料')], limit=1) + else: + embryo_redundancy_id = item.get('embryo_redundancy') vals = { 'name': '%s-%s-%s' % ('P', order_id.name, i), - 'model_long': item['model_long'] + model_type.embryo_tolerance, - 'model_width': item['model_width'] + model_type.embryo_tolerance, - 'model_height': item['model_height'] + model_type.embryo_tolerance, - 'model_volume': (item['model_long'] + model_type.embryo_tolerance) * ( - item['model_width'] + model_type.embryo_tolerance) * ( - item['model_height'] + model_type.embryo_tolerance), + 'model_long': item['model_long'] + embryo_redundancy_id.long, + 'model_width': item['model_width'] + embryo_redundancy_id.width, + 'model_height': item['model_height'] + embryo_redundancy_id.height, + 'model_volume': (item['model_long'] + embryo_redundancy_id.long) * ( + item['model_width'] + embryo_redundancy_id.width) * ( + item['model_height'] + embryo_redundancy_id.height), 'product_model_type_id': model_type.id, 'model_processing_panel': item['processing_panel_detail'], 'model_machining_precision': item['model_machining_precision'], @@ -933,6 +938,11 @@ class ResProductMo(models.Model): # surface_technology = self.env['stock.route'].sudo().search([('name', '=', '表面工艺外协')]) # if surface_technology: # no_bom_copy_product_id.route_ids |= surface_technology + # 获取坯料冗余配置 + if not item.get('embryo_redundancy_id'): + embryo_redundancy_id = self.env['sf.embryo.redundancy'].search([('name', '=', '粗坯料')], limit=1) + else: + embryo_redundancy_id = item.get('embryo_redundancy_id') no_bom_copy_product_id.product_tmpl_id.active = True logging.info('no_bom_copy_product_id[is_manual_processing]:%s' % no_bom_copy_product_id.is_manual_processing) materials_id = self.env['sf.production.materials'].search( @@ -945,15 +955,15 @@ class ResProductMo(models.Model): vals = { 'name': '%s-%s-%s [%s %s-%s * %s * %s]' % ('R', order_id.name, i, materials_id.name, materials_type_id.name, - item['model_long'] + model_type.embryo_tolerance, - item['model_width'] + model_type.embryo_tolerance, - item['model_height'] + model_type.embryo_tolerance), - 'length': item['model_long'] + model_type.embryo_tolerance, - 'width': item['model_width'] + model_type.embryo_tolerance, - 'height': item['model_height'] + model_type.embryo_tolerance, - 'volume': (item['model_long'] + model_type.embryo_tolerance) * ( - item['model_width'] + model_type.embryo_tolerance) * ( - item['model_height'] + model_type.embryo_tolerance), + item['model_long'] + embryo_redundancy_id.long, + item['model_width'] + embryo_redundancy_id.width, + item['model_height'] + embryo_redundancy_id.height), + 'length': item['model_long'] + embryo_redundancy_id.long, + 'width': item['model_width'] + embryo_redundancy_id.width, + 'height': item['model_height'] + embryo_redundancy_id.height, + 'volume': (item['model_long'] + embryo_redundancy_id.long) * ( + item['model_width'] + embryo_redundancy_id.width) * ( + item['model_height'] + embryo_redundancy_id.height), 'embryo_model_type_id': model_type.id, 'list_price': item['price'], 'materials_id': materials_id.id, diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index ee22696b..bcd7870e 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -133,7 +133,7 @@ class ReSaleOrder(models.Model): 'product_uom_qty': item['number'], 'model_glb_file': base64.b64decode(item['model_file']), 'remark': item.get('remark'), - 'is_incoming_material': item.get('is_incoming_material'), + 'embryo_redundancy_id': item.get('embryo_redundancy_id'), 'manual_quotation': item.get('manual_quotation') } return self.env['sale.order.line'].with_context(skip_procurement=True).create(vals) @@ -175,7 +175,8 @@ class ResaleOrderLine(models.Model): check_status = fields.Selection(related='order_id.check_status') remark = fields.Char('备注') - is_incoming_material = fields.Boolean('客供料', default=False) + # is_incoming_material = fields.Boolean('客供料', default=False) + embryo_redundancy_id = fields.Many2one('sf.embryo.redundancy', '坯料冗余') manual_quotation = fields.Boolean('人工编程', default=False) @api.depends('product_template_id') diff --git a/sf_sale/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml index a5adfcfa..5da88398 100644 --- a/sf_sale/views/sale_order_view.xml +++ b/sf_sale/views/sale_order_view.xml @@ -119,7 +119,7 @@ - + {'readonly': [('state', 'in', ['cancel','sale'])]} @@ -167,7 +167,7 @@ - +