计算总数量
This commit is contained in:
@@ -136,7 +136,18 @@ class QualityCheck(models.Model):
|
||||
# # 出厂检验报告编号
|
||||
# report_number = fields.Char('出厂检验报告编号', compute='_compute_report_number', readonly=True)
|
||||
# 总数量,值为调拨单_产品明细_数量
|
||||
total_qty = fields.Char('总数量', readonly=True)
|
||||
total_qty = fields.Char('总数量', compute='_compute_total_qty')
|
||||
|
||||
@api.depends('picking_id')
|
||||
def _compute_total_qty(self):
|
||||
for record in self:
|
||||
if record.picking_id:
|
||||
total_qty = 0
|
||||
for move in record.picking_id.move_ids_without_package:
|
||||
total_qty += move.quantity_done
|
||||
record.total_qty = total_qty if total_qty > 0 else ''
|
||||
else:
|
||||
record.total_qty = ''
|
||||
# 检验数
|
||||
check_qty = fields.Char('检验数', default=lambda self: self._get_default_check_qty())
|
||||
|
||||
@@ -149,7 +160,7 @@ class QualityCheck(models.Model):
|
||||
elif self._origin.measure_on == 'product':
|
||||
return '1'
|
||||
return ''
|
||||
|
||||
|
||||
@api.onchange('test_type_id', 'measure_on')
|
||||
def _onchange_check_qty(self):
|
||||
"""当测试类型或测量对象变化时,更新检验数"""
|
||||
@@ -166,7 +177,6 @@ class QualityCheck(models.Model):
|
||||
|
||||
categ_type = fields.Selection(string='产品的类别', related='product_id.categ_id.type', store=True)
|
||||
|
||||
|
||||
def add_measure_line(self):
|
||||
"""
|
||||
新增测量值,如果测量值有5列了,则提示“最多只能有5列测量值”
|
||||
@@ -209,7 +219,6 @@ class QualityCheck(models.Model):
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@depends('product_id')
|
||||
def _compute_material_name(self):
|
||||
for record in self:
|
||||
|
||||
Reference in New Issue
Block a user