Skip to Content
Menu
This question has been flagged
1 Reply
11531 Views

class DataArr(models.Model):
    _inherit = 'hr.pointage'

    @api.model
    def write(self, vals):

            # super(models.Model, self).write(vals)
            record = super(DataArr, self).write(vals)
            # d_check_in= vals['check_in']
            d_check_out= record.check_out
            return record


I wanted to get values of record edited  but it return this error:

d_check_out= record.check_out

AttributeError: 'bool' object has no attribute 'check_out'


I understood the error but how to get those values to continue coding, thanks in advance :)

Avatar
Discard
Best Answer

Hello, you are developing in new api, then you can do this if you want to see only if this fields was edited

if vals.get('check_out'):

     d_check_out = vals['check_out']

Otherwise if you want to obtain this field always I recommend use this way:

super(DataArr, self).write(vals)

for rec in self:

     rec.check_out

Write methods always return True or False if the write was succesfull never return an object, because that you can't do record.

Avatar
Discard