This is my xml file, focus on
Ghi nhận sản xuất
production.record
and this is my model:
class ProductionResult(models.Model):
_name = 'production.result'
production_record_id = fields.Many2one('production.record', string='Production Record')
planned_output_hour = fields.Float(string='Sản lượng kế hoạch/giờ')
so_volume = fields.Float(string='Khối lượng đơn hàng(thùng)')
mix_volume = fields.Float(string="Khối lượng trộn")
planned_output = fields.Float(string='Sản lượng kế hoạch (kg)')
actual_output_bin = fields.Float(string='Sản lượng thực tế (thùng)')
actual_output_kg = fields.Float(string ='Sản lượng thực tế(kg)')
completion_rate =fields.Float(string='Tỉ lệ hoàn thành(%)',compute='_compute_completion_rate',store=True)
is_operation_tron = fields.Boolean(string='Operation Tron',compute='_compute_is_operation_tron',default=False,store=True)
@api.depends('production_record_id.operation_id')
def _compute_is_operation_tron(self):
for rec in self:
if rec.production_record_id:
if rec.production_record_id.operation_id.name == 'Trộn':
rec.is_operation_tron = True
else:
rec.is_operation_tron = False
i can't invisible this column :
and i got this error:
Caused by: EvalError: Can not evaluate python expression: (bool(is_operation_tron != False))
Error: Name 'is_operation_tron' is not defined
but my default for is_operation_tron is False