Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化cnc程序
This commit is contained in:
@@ -321,26 +321,27 @@ class ToolMaterial(models.Model):
|
|||||||
specification_id = fields.Many2one('sf.tool.materials.basic.parameters', '规格',
|
specification_id = fields.Many2one('sf.tool.materials.basic.parameters', '规格',
|
||||||
related='product_id.specification_id')
|
related='product_id.specification_id')
|
||||||
image = fields.Binary('图片', related='product_id.image_1920')
|
image = fields.Binary('图片', related='product_id.image_1920')
|
||||||
number = fields.Integer('总数量', readonly=True, compute='_compute_number')
|
number = fields.Integer('总数量', compute='_compute_number')
|
||||||
usable_num = fields.Integer('可用数量', readonly=True)
|
usable_num = fields.Integer('可用数量', compute='_compute_number')
|
||||||
have_been_used_num = fields.Integer('在用数量', readonly=True)
|
have_been_used_num = fields.Integer('在用数量', compute='_compute_number')
|
||||||
scrap_num = fields.Integer('报废数量', readonly=True)
|
scrap_num = fields.Integer('报废数量', compute='_compute_number')
|
||||||
|
|
||||||
barcode_ids = fields.One2many('stock.lot', 'tool_material_search_id', string='序列号', readonly=True)
|
barcode_ids = fields.One2many('stock.lot', 'tool_material_search_id', string='序列号', readonly=True)
|
||||||
|
|
||||||
@api.depends('barcode_ids')
|
@api.depends('barcode_ids')
|
||||||
def _compute_number(self):
|
def _compute_number(self):
|
||||||
usable_num = 0
|
|
||||||
have_been_used_num = 0
|
|
||||||
scrap_num = 0
|
|
||||||
for record in self:
|
for record in self:
|
||||||
|
usable_num = 0
|
||||||
|
have_been_used_num = 0
|
||||||
|
scrap_num = 0
|
||||||
if record.barcode_ids:
|
if record.barcode_ids:
|
||||||
record.number = len(record.barcode_ids)
|
record.number = len(record.barcode_ids)
|
||||||
for barcode_id in record.barcode_ids:
|
for barcode_id in record.barcode_ids:
|
||||||
if barcode_id.quant_ids[-1].location_id.name == '刀具组装位置':
|
if barcode_id.quant_ids:
|
||||||
have_been_used_num = have_been_used_num + 1
|
if barcode_id.quant_ids[-1].location_id.name == '刀具组装位置':
|
||||||
else:
|
have_been_used_num = have_been_used_num + 1
|
||||||
usable_num = usable_num + 1
|
else:
|
||||||
|
usable_num = usable_num + 1
|
||||||
record.usable_num = usable_num
|
record.usable_num = usable_num
|
||||||
record.have_been_used_num = have_been_used_num
|
record.have_been_used_num = have_been_used_num
|
||||||
record.scrap_num = scrap_num
|
record.scrap_num = scrap_num
|
||||||
|
|||||||
Reference in New Issue
Block a user