解决刀具物料搜索的计算字段数据问题;

This commit is contained in:
yuxianghui
2024-02-26 11:39:25 +08:00
parent 6c98ea7781
commit 690c388143

View File

@@ -321,19 +321,19 @@ 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('总数量', readonly=True, compute='_compute_number')
usable_num = fields.Integer('可用数量', readonly=True)
have_been_used_num = fields.Integer('在用数量', readonly=True)
scrap_num = fields.Integer('报废数量', readonly=True)
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('barcode_ids')
def _compute_number(self):
usable_num = 0
have_been_used_num = 0
scrap_num = 0
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: