Merge branch 'fix/15.0/hr_payroll_hibou__upstream_precision' into '15.0'

WIP: fix/15.0/hr_payroll_hibou__upstream_precision into 15.0

See merge request hibou-io/hibou-odoo/suite!1375
This commit is contained in:
Jared Kipe
2022-03-22 16:05:43 +00:00
2 changed files with 13 additions and 2 deletions

View File

@@ -3,7 +3,7 @@
{ {
'name': 'Hibou Payroll', 'name': 'Hibou Payroll',
'author': 'Hibou Corp. <hello@hibou.io>', 'author': 'Hibou Corp. <hello@hibou.io>',
'version': '15.0.2.0.0', 'version': '15.0.2.1.0',
'category': 'Payroll Localization', 'category': 'Payroll Localization',
'depends': [ 'depends': [
'hr_payroll', 'hr_payroll',
@@ -16,6 +16,7 @@ Hibou Payroll
Base module for fixing specific qwerks or assumptions in the way Payroll Odoo Enterprise Edition behaves. 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': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',

View File

@@ -1,15 +1,25 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. # 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): class HrPayslip(models.Model):
_inherit = 'hr.payslip' _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, # We need to be able to support more complexity,
# namely, that different employees will be paid by different wage types as 'salary' vs 'hourly' # namely, that different employees will be paid by different wage types as 'salary' vs 'hourly'
wage_type = fields.Selection(related='contract_id.wage_type') 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): def get_year(self):
""" """
# Helper method to get the year (normalized between Odoo Versions) # Helper method to get the year (normalized between Odoo Versions)