I used the attendance validation in my custom class.I used @api.constrain that triggers following method when there is change to 's2' field
@api.constrains('s2')def constraint_action(self,cr, uid, ids, context=None):
for att in self.browse(cr, uid, ids, context=context):
# search and browse for first previous and first next records
prev_att_ids = self.search(cr, uid, [('EID', '=', att.EID), ('date', '<', att.date),
('action', 'in', ('sign_in', 'sign_out'))], limit=1, order='date DESC')
next_add_ids = self.search(cr, uid, [('EID', '=', att.EID), ('date', '>', att.date),
('action', 'in', ('sign_in', 'sign_out'))], limit=1, order='date ASC')
prev_atts = self.browse(cr, uid, prev_att_ids, context=context)
next_atts = self.browse(cr, uid, next_add_ids, context=context)
# check for alternance, return False if at least one condition is not satisfied
if prev_atts and prev_atts[0].action == att.action: # previous exists and is same action
self._columns('state' '=' 'True')-----------------------------> This doesn't work
return True
I declared following variables at starting
class attendance(models.Model):
_name = "attendance.analysis"
_description = "attendance analysis"
_state = fields.boolean("state?",default = False)
_columns = { 'EID': fields.integer('Employee ID', required=True),
'action': fields.selection([('sign_in', 'Sign In'), ('sign_out', 'Sign Out')], 'Employee Action'),
'date': fields.datetime('Employee Date', required=True, select=1),
's1':fields.char("s1"),
's2':fields.char("s2", required=True),
's3':fields.char("s3"),
's4':fields.char("s4"),
'state':fields.boolean("state?",default = False)
}
I want to access the state field in columns. How can I access it
I want to change this boolean so that tree color can be changed on the view.xml.
Thanks in advance
In this link https://www.odoo.com/fr_FR/forum/aide-1/question/attributeerror-my-model-name-object-has-no-attribute-env-94569 they are accessing function written in old api from new api .But in my case I want to access the new api class column variable inside my old api function(def constraint_action(self,cr, uid, ids, context=None)