itpp-labs/l10n-addons

odoo 10 calculated field

Closed this issue · 0 comments

Hello now i am calculating a field but the result does not appears.

class HrEmployee(models.Model):
_inherit = 'hr.employee'

@api.multi
def _calculate_social_parts(self):
    parts = 1.00
    for line in self:
        if line.marital == 'married':
            if line.status_spouse == 'non_salaried':
                parts += 1.00
            else:
                parts += 0.50
        if line.children:
            parts += float(line.children) / 2
        if parts > 5.00:
            parts = 5.00
        line.parts = parts

@api.multi
def _calculate_coefficient(self):
    for line in self:
        if line.marital == 'married':
            coef = 2 if line.status_spouse == 'non_salaried' else 1
        else:
            coef = 1
        line.coef = coef

@api.multi
def _user_left_days(self):
    for employee in self:
        legal_leave = employee.company_id.legal_holidays_status_id
        values = legal_leave.get_days(employee.id)
        employee.leaves_taken = values.get('leaves_taken')
        employee.max_leaves = values.get('max_leaves')

social_parts = fields.Float(compute="_calculate_social_parts", method=True, string="Nombre de parts sociales", store=False)
ipres_id = fields.Char('N° IPRES')
css_id = fields.Char('N° Sécurité Sociale')
status_spouse = fields.Selection((('salaried', 'Salarié(e)'), ('non_salaried', 'Non-salarié(e)')), string='Statut du/de la conjoint(e)', default='salaried')
coef = fields.Integer(compute="_calculate_coefficient", method=True, string="Coefficient de TRIMF", store=True)
matricule = fields.Char('Matricule', size=64)
max_leaves = fields.Float(compute="_user_left_days", string='Acquis', help='This value is given by the sum of all holidays requests with a positive value.',)
leaves_taken = fields.Float(compute="_user_left_days", string='Pris', help='This value is given by the sum of all holidays requests with a negative value.',)

Problem:social_parts stay at 0.00