I want to display some text in the form view of odoo. The text should be displayed below the sheet. I have one field name "state" it is a boolean value. If the state is true the it should display some text and if it is false it should display some text in the form view.
The hr_attendance module has validation to import a file into odoo the validation contains three "if" condition I have edited this condition so that it will import the record even it is wrong and it will show the field in red color in tree view.
Here is the code
hr_attendance.py
def _altern_si_so(self, cr, uid, ids, context=None):
""" Alternance sign_in/sign_out check.
Previous (if exists) must be of opposite action.
Next (if exists) must be of opposite action.
"""
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, [('employee_id', '=', att.employee_id.id), ('name', '<', att.name),
('action', 'in', ('sign_in', 'sign_out'))], limit=1, order='name DESC')
next_add_ids = self.search(cr, uid, [('employee_id', '=', att.employee_id.id), ('name', '>', att.name),
('action', 'in', ('sign_in', 'sign_out'))], limit=1, order='name 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:
return self.write(cr, uid, ids, {'state': True})
if next_atts and next_atts[0].action == att.action: # next exists and is same action
return self.write(cr, uid, ids, {'state': True})
if (not prev_atts) and (not next_atts) and att.action != 'sign_in': # first attendance must be sign_in
return self.write(cr, uid, ids, {'state': True})
else:
return self.write(cr, uid, ids, {'state':False})
return True
_constraints = [
(_altern_si_so, 'Error ! Sign in (resp. Sign out) must follow Sign out (resp. Sign in)', ['action'])]
hr_attendance_view.xml
<field name="arch" type="xml"> <tree string="Employee attendances" colors="red:state == True;black:state == False"> <field name="name"/>
Now I want to display some text in the form view. If I click the wrong field(which displays red color in the tree view) the form view will be open. I want to display a text below the form view sheet. So that the text describes what is the error in the field.
Thanks...
Is this possible or not? Is there any way to show some text below the form view?