1、功能刀具清单模型添加功能刀具名称重名检验,2、功能刀具安全库存模型添加根据所选功能刀具名称自动带出类型、刀具组、直径、R角信息;3、优化刀具物料搜索模型,物料数量字段改为存储字段,根据对应产品的各个位置的库存数量自动计算刀具物料的总数等值;

This commit is contained in:
yuxianghui
2024-04-11 17:34:15 +08:00
parent 010fbb23b0
commit 4391a4e145
4 changed files with 47 additions and 43 deletions

View File

@@ -20,14 +20,14 @@ class ToolMaterial(models.Model):
specification_id = fields.Many2one('sf.tool.materials.basic.parameters', '规格',
related='product_id.specification_id')
image = fields.Binary('图片', related='product_id.image_1920')
number = fields.Integer('总数量', compute='_compute_number')
usable_num = fields.Integer('可用数量', compute='_compute_number')
have_been_used_num = fields.Integer('在用数量', compute='_compute_number')
scrap_num = fields.Integer('报废数量', compute='_compute_number')
number = fields.Integer('总数量', compute='_compute_number', store=True)
usable_num = fields.Integer('可用数量', compute='_compute_number', store=True)
have_been_used_num = fields.Integer('在用数量', compute='_compute_number', store=True)
scrap_num = fields.Integer('报废数量', compute='_compute_number', store=True)
barcode_ids = fields.One2many('stock.lot', 'tool_material_search_id', string='序列号', readonly=True)
@api.depends('product_id')
@api.depends('product_id.stock_quant_ids.quantity')
def _compute_number(self):
for record in self:
usable_num = 0
@@ -47,29 +47,8 @@ class ToolMaterial(models.Model):
record.have_been_used_num = have_been_used_num
record.scrap_num = scrap_num
record.number = usable_num + have_been_used_num + scrap_num
# @api.depends('barcode_ids')
# def _compute_number(self):
# for record in self:
# usable_num = 0
# have_been_used_num = 0
# scrap_num = 0
# if record.barcode_ids:
# record.number = len(record.barcode_ids)
# for barcode_id in record.barcode_ids:
# if barcode_id.quant_ids:
# if barcode_id.quant_ids[-1].location_id.name == '刀具组装位置':
# have_been_used_num = have_been_used_num + 1
# else:
# usable_num = usable_num + 1
# record.usable_num = usable_num
# record.have_been_used_num = have_been_used_num
# record.scrap_num = scrap_num
# else:
# record.number = 0
# record.usable_num = 0
# record.have_been_used_num = 0
# record.scrap_num = 0
# 更新数据到cloud的动态数据
record.enroll_tool_material()
@api.model
def _read_group_cutting_tool_material_id(self, categories, domain, order):