优化了功能刀具组装对象组装和取消组装时功能刀具列表的many2many类型字段赋值为[]时值不修改的问题

This commit is contained in:
yuxianghui
2023-08-04 16:24:12 +08:00
parent 7f6ea605d2
commit cd042a8073
2 changed files with 19 additions and 9 deletions

View File

@@ -270,8 +270,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'applicable_range': record.applicable_range,
'image': record.image,
})
# 修改功能刀具列表信息
record.write(desc_2)
# 删除功能刀具列表信息
self.env['sf.functional.cutting.tool.entity'].search([('code', '=', self.code)]).unlink()
# 创建功能刀具列表信息
self.env['sf.functional.cutting.tool.entity'].search([('code', '=', self.code)]).create(desc_2)
# # 创建功能刀具预警、实时分布、出入库记录的新记录
# self.env['sf.functional.tool.warning'].create(desc)
# self.env['sf.real.time.distribution.of.functional.tools'].create(desc)
@@ -300,10 +302,12 @@ class DeliveryOfCargoFromStorage(models.TransientModel):
:return:
"""
vals = self.env['sf.delivery.of.cargo.from.storage'].search([])
print(vals)
if vals:
for val in vals:
print(val)
# 删除功能刀具列表缓存的数据
self.env['sf.functional.cutting.tool.entity.cache'].search([
('code', '=', self.functional_tool_code)]).unlink()
record = self.env['sf.functional.tool.assembly'].search([
('functional_tool_code', '=', val.functional_tool_code),
('assemble_status', '=', '1')