Hello everyone, I have 2 classes like in the picture.
In the overtime_detail class, I have created a list of records, all of which are defaulted in the "draft" state.
'' class overtime_detail (models.Model):
_name = 'overtime_detail'
_description = "More details"
_rec_name = 'employee'
employee = fields.Many2one (comodel_name = 'hr.employee', string = "Employee name", required = True)
department = fields.Many2one (comodel_name = 'hr.department', string = 'Department', required = True)
date = fields.Date (string = 'Overtime day', default = datetime.today (), required = True)
ot_rate = fields.Float (string = 'Overtime rate')
ot_time = fields.Integer (string = "Overtime", min = '0.5', max = '16 ', required = True)
reason = fields.Char (string = "Reason for overtime", size = 100, required = True)
status = fields.Selection (string = 'Status', selection = [('draft', 'Draft'),
('wait', 'Wait for approval'),
('done', 'Approved'),
('reject', 'Rejected')], default = 'draft')
management = fields.Many2one (comodel_name = 'overtime_management', string = 'Description') ''
In class overtime_management
class overtime_management (models.Model):
_name = "overtime_management"
_description = "Overtime ticket"
_rec_name = 'department'
subject = fields.Char (string = 'Description', required = True)
department = fields.Many2one (comodel_name = 'hr.department', string = 'Department', required = True)
date = fields.Date (string = 'Overtime day', required = True)
ot_rate = fields.Float ("Overtime rate", required = True)
ot_sum = fields.Float ("Total overtime", compute = '_ sum_ot')
reason = fields.Char (string = 'Reason for overtime', size = 100, required = True)
detail = fields.One2many (comodel_name = 'overtime_detail', inverse_name = 'management', string = "More details")
status = fields.Selection (string = "Status", selection =
[('draft', 'Draft'),
('done', 'Approved'),
('reject', 'Rejected')], default = 'draft')
This class has a many2one relationship with overtime_detail. I want to create an "approved" button that converts the state of detail records in overtime_detail to "approved". Please help me. Thank you
Look into odoo workflow: https://goo.gl/gYe8RL