Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2076 Ansichten

Hi Forum!

For some reason, the remaining field is not updated when a new value is added ,why can this be?

yearly_pool = fields.Integer(string='Yearly pool')
working_days = fields.Integer(string='Wordkdays count', compute='_compute_working_days', store=True)
remaining = fields.Integer(string='Remaining', compute='_compute_remaining', store=True)
holidays_ids = fields.Many2many('hr.holidays', string='Freedoms allowed ', compute='_compute_holidays_ids')

Field methods:

remaining:

@api.multi
@api.depends('yearly_pool', 'working_days')
def _compute_remaining(self):
for record in self:
record.remaining = record.yearly_pool - record.working_days

working_days:

@api.multi
@api.depends('holidays_ids')
def _compute_working_days(self):
for record in self:
record.working_days = sum(record.holidays_ids.mapped('working_days'))

holiday_ids:

@api.multi
def _compute_holidays_ids(self):
for record in self:
record.holidays_ids = self.env['hr.holidays'].search([
('employee_id', '=', record.employee_id.id),
('year', '=', record.year),
('state', '=', 'validate'),
])

Thank you for your help!

Regards,
Steven



Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
März 15
3560
3
Sept. 24
1507
0
Dez. 23
1415
1
Feb. 22
7175
0
Okt. 21
3030