bom物料清单添加错误信息,添加刀具物料字段展示
This commit is contained in:
@@ -3,4 +3,4 @@ from odoo import models, fields
|
||||
|
||||
class SyncFunctionalCuttingToolModel(models.Model):
|
||||
_inherit = 'sf.functional.cutting.tool.model'
|
||||
cutting_tool_type_ids = fields.Many2many('sf.cutting.tool.type', string='整体式刀具物料')
|
||||
cutting_tool_type_ids = fields.Many2many('sf.cutting.tool.type', string='刀具物料类型')
|
||||
@@ -2,6 +2,7 @@
|
||||
from xml import etree
|
||||
|
||||
from odoo import models, fields, api, Command
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.http import request
|
||||
|
||||
|
||||
@@ -26,26 +27,28 @@ class jikimo_bom(models.Model):
|
||||
for bom in self:
|
||||
result.append((bom.id, '功能刀具物料清单'))
|
||||
return result
|
||||
|
||||
def bom_product_domains(self, assembly_options):
|
||||
self.options = assembly_options
|
||||
cutting_tool_materials = self.env['sf.cutting.tool.material'].search(
|
||||
[('name', 'in', assembly_options.split('+'))])
|
||||
domains = []
|
||||
for index, option in enumerate(cutting_tool_materials):
|
||||
domain = ['&',('cutting_tool_material_id', '=', option.id),
|
||||
domain = ['&', ('cutting_tool_material_id', '=', option.id),
|
||||
("cutting_tool_type_id", "in",
|
||||
self.tool_inventory_id.functional_cutting_tool_model_id.cutting_tool_type_ids.ids)]
|
||||
if option.name == '刀柄':
|
||||
domain = ['&']+domain+[ ("cutting_tool_taper_shank_model", "=", self.tool_inventory_id.knife_handle_model)]
|
||||
domain = ['&'] + domain + [
|
||||
("cutting_tool_taper_shank_model", "=", self.tool_inventory_id.knife_handle_model)]
|
||||
|
||||
if option.name == '整体式刀具':
|
||||
domain=['&']+domain+[
|
||||
'|',
|
||||
# 刀具直径
|
||||
('cutting_tool_blade_diameter', '=', self.tool_inventory_id.diameter),
|
||||
domain = ['&'] + domain + [
|
||||
'|',
|
||||
# 刀具直径
|
||||
('cutting_tool_blade_diameter', '=', self.tool_inventory_id.diameter),
|
||||
|
||||
# r角
|
||||
('cutting_tool_blade_tip_working_size', '=', self.tool_inventory_id.angle)]
|
||||
# r角
|
||||
('cutting_tool_blade_tip_working_size', '=', self.tool_inventory_id.angle)]
|
||||
if option.name == '刀杆':
|
||||
domain = ['&'] + domain + [
|
||||
("cutting_tool_cutter_arbor_diameter", "=", self.tool_inventory_id.diameter)]
|
||||
@@ -55,7 +58,7 @@ class jikimo_bom(models.Model):
|
||||
if option.name == '刀盘':
|
||||
domain = ['&'] + domain + [
|
||||
("cutting_tool_cutter_head_diameter", "=", self.tool_inventory_id.diameter)]
|
||||
domains=domains+domain
|
||||
domains = domains + domain
|
||||
if index != 0:
|
||||
domains = ['|'] + domains
|
||||
# wqwqwe = self.env['product.product'].search(ddd)
|
||||
@@ -65,7 +68,7 @@ class jikimo_bom(models.Model):
|
||||
return domains
|
||||
|
||||
def generate_bill_materials(self, assembly_options):
|
||||
domains=self.bom_product_domains(assembly_options)
|
||||
domains = self.bom_product_domains(assembly_options)
|
||||
products = self.env['product.product'].search(domains)
|
||||
if products:
|
||||
self.product_ids = [Command.set(products.ids)]
|
||||
@@ -91,6 +94,9 @@ class ProductProduct(models.Model):
|
||||
# 例如,添加额外的搜索条件
|
||||
if self.env.context.get('jikimo_bom_product'):
|
||||
bom_id = self.env['jikimo.bom'].browse(request.session.get('jikimo_bom_product').get('bom_id'))
|
||||
|
||||
if not bom_id.options:
|
||||
raise UserError('请先选择组装方式')
|
||||
domains = bom_id.bom_product_domains(bom_id.options)
|
||||
args=args+domains
|
||||
args = args + domains
|
||||
return super(ProductProduct, self).search(args, offset=offset, limit=limit, order=order, count=count)
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
<field name="product_ids" context="{'jikimo_bom_product': True}">
|
||||
<tree>
|
||||
<field name="name"/>
|
||||
<field name="categ_id"/>
|
||||
<!-- <field name="categ_id"/>-->
|
||||
<field name="cutting_tool_material_id"/>
|
||||
<field name="cutting_tool_model_id"/>
|
||||
<field name="specification_id"/>
|
||||
<field name="brand_id"/>
|
||||
|
||||
Reference in New Issue
Block a user