From 6e4bb1bc97524d48a59fad5d582bab8d7ef50972 Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Mon, 21 Mar 2022 17:43:38 +0000 Subject: [PATCH] [FIX] hr_payroll_hibou: patch upstream field from Int to Float --- hr_payroll_hibou/__manifest__.py | 3 ++- hr_payroll_hibou/models/hr_payslip.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hr_payroll_hibou/__manifest__.py b/hr_payroll_hibou/__manifest__.py index 86a1a11a..0345956b 100644 --- a/hr_payroll_hibou/__manifest__.py +++ b/hr_payroll_hibou/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Hibou Payroll', 'author': 'Hibou Corp. ', - 'version': '15.0.2.0.0', + 'version': '15.0.2.1.0', 'category': 'Payroll Localization', 'depends': [ 'hr_payroll', @@ -16,6 +16,7 @@ Hibou Payroll Base module for fixing specific qwerks or assumptions in the way Payroll Odoo Enterprise Edition behaves. +2.1.0 : fixes precision error in upstream by changing `normal_wage` field from Integer to Float """, 'data': [ 'security/ir.model.access.csv', diff --git a/hr_payroll_hibou/models/hr_payslip.py b/hr_payroll_hibou/models/hr_payslip.py index fab438f5..06f1031f 100644 --- a/hr_payroll_hibou/models/hr_payslip.py +++ b/hr_payroll_hibou/models/hr_payslip.py @@ -1,15 +1,25 @@ # Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. -from odoo import fields, models +from odoo import api, fields, models class HrPayslip(models.Model): _inherit = 'hr.payslip' + # normal_wage is an integer field, but that lacks precision. + normal_wage = fields.Float(compute='_compute_normal_wage', store=True) # We need to be able to support more complexity, # namely, that different employees will be paid by different wage types as 'salary' vs 'hourly' wage_type = fields.Selection(related='contract_id.wage_type') + @api.depends('contract_id') + def _compute_normal_wage(self): + with_contract = self.filtered('contract_id') + # fixes bug in original computation if the size of the recordset is >1 + (self - with_contract).update({'normal_wage': 0.0}) + for payslip in with_contract: + payslip.normal_wage = payslip._get_contract_wage() + def get_year(self): """ # Helper method to get the year (normalized between Odoo Versions)