bom清单问题修复
This commit is contained in:
@@ -50,7 +50,7 @@ class jikimo_bom(models.Model):
|
|||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
# 在更新模型时记录旧的 Many2many ID 列表
|
# 在更新模型时记录旧的 Many2many ID 列表
|
||||||
if 'product_ids' in vals:
|
if 'product_ids' in vals and not self.env.context.get('is_assembly_options'):
|
||||||
old_product_counter = Counter(self.product_ids.ids)
|
old_product_counter = Counter(self.product_ids.ids)
|
||||||
super(jikimo_bom, self).write(vals)
|
super(jikimo_bom, self).write(vals)
|
||||||
new_product_counter = Counter(self.product_ids.ids)
|
new_product_counter = Counter(self.product_ids.ids)
|
||||||
@@ -102,7 +102,7 @@ class jikimo_bom(models.Model):
|
|||||||
domains = domains + domain
|
domains = domains + domain
|
||||||
if index != 0:
|
if index != 0:
|
||||||
domains = ['|'] + domains
|
domains = ['|'] + domains
|
||||||
domains = domains + [('stock_move_count', '>', 0)]
|
domains = domains + [('stock_move_ids', '!=',False)]
|
||||||
return domains
|
return domains
|
||||||
|
|
||||||
def generate_bill_materials(self, assembly_options):
|
def generate_bill_materials(self, assembly_options):
|
||||||
@@ -117,7 +117,10 @@ class jikimo_bom(models.Model):
|
|||||||
domains = self.bom_product_domains(assembly_options)
|
domains = self.bom_product_domains(assembly_options)
|
||||||
products = self.env['product.product'].search(domains)
|
products = self.env['product.product'].search(domains)
|
||||||
if products:
|
if products:
|
||||||
self.product_ids = [Command.set(products.ids)]
|
new_context = dict(self.env.context)
|
||||||
|
new_context['is_assembly_options'] = True
|
||||||
|
self.with_context(new_context).write({'product_ids': [Command.set(products.ids)]})
|
||||||
|
# self.product_ids = [Command.set(products.ids)]
|
||||||
|
|
||||||
|
|
||||||
class jikimo_bom_line(models.Model):
|
class jikimo_bom_line(models.Model):
|
||||||
@@ -130,15 +133,15 @@ class jikimo_bom_line(models.Model):
|
|||||||
class ProductProduct(models.Model):
|
class ProductProduct(models.Model):
|
||||||
_inherit = 'product.product'
|
_inherit = 'product.product'
|
||||||
_order = 'cutting_tool_material_id, cutting_tool_type_id'
|
_order = 'cutting_tool_material_id, cutting_tool_type_id'
|
||||||
stock_move_count = fields.Integer(string='stock_move count', compute='_compute_stock_move_count', store=True)
|
# stock_move_count = fields.Integer(string='stock_move count', compute='_compute_stock_move_count')
|
||||||
|
#
|
||||||
@api.depends('stock_move_ids')
|
# @api.depends('stock_move_ids')
|
||||||
def _compute_stock_move_count(self):
|
# def _compute_stock_move_count(self):
|
||||||
for record in self:
|
# for record in self:
|
||||||
if record.stock_move_ids:
|
# if record.stock_move_ids:
|
||||||
record.stock_move_count = len(record.stock_move_ids)
|
# record.stock_move_count = len(record.stock_move_ids)
|
||||||
else:
|
# else:
|
||||||
record.stock_move_count = 0
|
# record.stock_move_count = 0
|
||||||
|
|
||||||
def search(self, args, offset=0, limit=None, order=None, count=False):
|
def search(self, args, offset=0, limit=None, order=None, count=False):
|
||||||
# 你可以在这里修改 `args` 以调整搜索条件
|
# 你可以在这里修改 `args` 以调整搜索条件
|
||||||
|
|||||||
@@ -6,10 +6,32 @@
|
|||||||
<field name="inherit_id" ref="sf_base.view_tool_inventory_tree"/>
|
<field name="inherit_id" ref="sf_base.view_tool_inventory_tree"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='extension']" position="before">
|
<xpath expr="//field[@name='extension']" position="before">
|
||||||
<field name="knife_handle_model" />
|
<field name="knife_handle_model" class="o-sticky-header"/>
|
||||||
<button name="bom_mainfest" string="bom清单" type="object" class="btn-link"
|
<button name="bom_mainfest" string="bom清单" type="object" class="btn-link"
|
||||||
icon="fa-refresh" />
|
icon="fa-refresh"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="view_tool_inventory_inherit_search" model="ir.ui.view">
|
||||||
|
<field name="name">sf.tool.inventory.inherit.search</field>
|
||||||
|
<field name="model">sf.tool.inventory</field>
|
||||||
|
<field name="inherit_id" ref="sf_base.view_cutting_tool_material_search"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='extension']" position="after">
|
||||||
|
<searchpanel>
|
||||||
|
<field name="knife_handle_model" enable_counters="1"/>
|
||||||
|
<!-- <field name="job_id" enable_counters="1"/>-->
|
||||||
|
<!-- <field name="department_id" enable_counters="1"/>-->
|
||||||
|
<!-- <field name="company_id" enable_counters="1"/>-->
|
||||||
|
</searchpanel>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<!-- <searchpanel>-->
|
||||||
|
<!-- <field name="org_type_id_display" enable_counters="1"/>-->
|
||||||
|
<!-- <!– <field name="job_id" enable_counters="1"/>–>-->
|
||||||
|
<!-- <field name="department_id" enable_counters="1"/>-->
|
||||||
|
<!-- <!– <field name="company_id" enable_counters="1"/>–>-->
|
||||||
|
<!-- </searchpanel>-->
|
||||||
</odoo>
|
</odoo>
|
||||||
Reference in New Issue
Block a user