bom清单问题修复
This commit is contained in:
@@ -50,7 +50,7 @@ class jikimo_bom(models.Model):
|
||||
|
||||
def write(self, vals):
|
||||
# 在更新模型时记录旧的 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)
|
||||
super(jikimo_bom, self).write(vals)
|
||||
new_product_counter = Counter(self.product_ids.ids)
|
||||
@@ -102,7 +102,7 @@ class jikimo_bom(models.Model):
|
||||
domains = domains + domain
|
||||
if index != 0:
|
||||
domains = ['|'] + domains
|
||||
domains = domains + [('stock_move_count', '>', 0)]
|
||||
domains = domains + [('stock_move_ids', '!=',False)]
|
||||
return domains
|
||||
|
||||
def generate_bill_materials(self, assembly_options):
|
||||
@@ -117,7 +117,10 @@ class jikimo_bom(models.Model):
|
||||
domains = self.bom_product_domains(assembly_options)
|
||||
products = self.env['product.product'].search(domains)
|
||||
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):
|
||||
@@ -130,15 +133,15 @@ class jikimo_bom_line(models.Model):
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
_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)
|
||||
|
||||
@api.depends('stock_move_ids')
|
||||
def _compute_stock_move_count(self):
|
||||
for record in self:
|
||||
if record.stock_move_ids:
|
||||
record.stock_move_count = len(record.stock_move_ids)
|
||||
else:
|
||||
record.stock_move_count = 0
|
||||
# stock_move_count = fields.Integer(string='stock_move count', compute='_compute_stock_move_count')
|
||||
#
|
||||
# @api.depends('stock_move_ids')
|
||||
# def _compute_stock_move_count(self):
|
||||
# for record in self:
|
||||
# if record.stock_move_ids:
|
||||
# record.stock_move_count = len(record.stock_move_ids)
|
||||
# else:
|
||||
# record.stock_move_count = 0
|
||||
|
||||
def search(self, args, offset=0, limit=None, order=None, count=False):
|
||||
# 你可以在这里修改 `args` 以调整搜索条件
|
||||
|
||||
Reference in New Issue
Block a user