Skip to content

Commit

Permalink
[MIG] payroll: Migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mtelahun committed Nov 10, 2022
1 parent 9984698 commit b3970c1
Show file tree
Hide file tree
Showing 31 changed files with 235 additions and 355 deletions.
48 changes: 5 additions & 43 deletions payroll/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Payroll
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpayroll-lightgray.png?logo=github
:target: https://github.com/OCA/payroll/tree/14.0/payroll
:target: https://github.com/OCA/payroll/tree/15.0/payroll
:alt: OCA/payroll
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/payroll-14-0/payroll-14-0-payroll
:target: https://translation.odoo-community.org/projects/payroll-15-0/payroll-15-0-payroll
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/281/14.0
:target: https://runbot.odoo-community.org/runbot/281/15.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -34,51 +34,13 @@ This module is a backport from Odoo SA and as such, it is not included in the OC
.. contents::
:local:

Changelog
=========

14.0.6.0.0 (2022-11-04)
~~~~~~~~~~~~~~~~~~~~~~~

* #87 payroll_rule_time_parameter: remove from payroll
* Removed hr.rule.parameter & hr.rule.parameter.value (see payroll_rule_time_parameter)

14.0.5.3.0 (2022-09-13)
~~~~~~~~~~~~~~~~~~~~~~~

* #67 Merge payslip_cancel and payslip_change_state in base module
* Merged hr_payroll_cancel, adding a setting to enable this feature (by default disabled).
* Merged hr_payroll_change_state (there is no setting to disable this feature).

14.0.5.0.0 (2022-08-29)
~~~~~~~~~~~~~~~~~~~~~~~

* #60 Improve views, add child functionalities, allow compute of name

14.0.4.0.0 (2022-08-17)
~~~~~~~~~~~~~~~~~~~~~~~

* #45 Remove contract_advantage_template model and new module
* Removed hr.contract.advantage.template (moved to payroll_contract_advantages)

14.0.3.0.0 (2022-08-15)
~~~~~~~~~~~~~~~~~~~~~~~

* #47 payslip refactoring

14.0.2.0.0 (2022-07-07)
~~~~~~~~~~~~~~~~~~~~~~~

* #31 major-rule-parameters-function
* Added hr.rule.parameter & hr.rule.parameter.value

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/payroll/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/payroll/issues/new?body=module:%20payroll%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/payroll/issues/new?body=module:%20payroll%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -123,6 +85,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-appstogrow| |maintainer-nimarosa|

This module is part of the `OCA/payroll <https://github.com/OCA/payroll/tree/14.0/payroll>`_ project on GitHub.
This module is part of the `OCA/payroll <https://github.com/OCA/payroll/tree/15.0/payroll>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion payroll/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{
"name": "Payroll",
"version": "14.0.6.1.0",
"version": "15.0.1.0.0",
"category": "Payroll",
"website": "https://github.com/OCA/payroll",
"sequence": 38,
Expand Down
22 changes: 10 additions & 12 deletions payroll/data/hr_payroll_data.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<!-- Decimal Precision -->
<record forcecreate="True" id="decimal_payroll" model="decimal.precision">
<field name="name">Payroll</field>
<field name="digits">2</field>
</record>
<record forcecreate="True" id="decimal_payroll_rate" model="decimal.precision">
<field name="name">Payroll Rate</field>
<field name="digits">4</field>
</record>
</data>
<odoo noupdate="1">
<!-- Decimal Precision -->
<record forcecreate="True" id="decimal_payroll" model="decimal.precision">
<field name="name">Payroll</field>
<field name="digits">2</field>
</record>
<record forcecreate="True" id="decimal_payroll_rate" model="decimal.precision">
<field name="name">Payroll Rate</field>
<field name="digits">4</field>
</record>
</odoo>
16 changes: 7 additions & 9 deletions payroll/data/hr_payroll_sequence.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<record id="seq_salary_slip" model="ir.sequence">
<field name="name">Salary Slip</field>
<field name="code">salary.slip</field>
<field name="prefix">SLIP/</field>
<field name="padding">3</field>
</record>
</data>
<odoo noupdate="1">
<record id="seq_salary_slip" model="ir.sequence">
<field name="name">Salary Slip</field>
<field name="code">salary.slip</field>
<field name="prefix">SLIP/</field>
<field name="padding">3</field>
</record>
</odoo>
1 change: 0 additions & 1 deletion payroll/demo/hr_payroll_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ ref('hr_salary_rule_convanceallowance1'),ref('hr_salary_rule_professionaltax1'),
<field name="company_id" ref="base.main_company" />
<field eval="1" name="active" />
<field name="name">Roger Scott</field>
<field name="work_location">Building 1, Second Floor</field>
<field name="work_phone">+3282823500</field>
<field
name="image_1920"
Expand Down
1 change: 1 addition & 0 deletions payroll/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from . import hr_contract
from . import hr_employee
from . import hr_leave_type
from . import hr_payroll_structure
from . import hr_salary_rule
from . import hr_salary_rule_category
Expand Down
1 change: 0 additions & 1 deletion payroll/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class HrEmployee(models.Model):
)
payslip_count = fields.Integer(
compute="_compute_payslip_count",
string="Payslip Count",
groups="payroll.group_payroll_user",
)

Expand Down
10 changes: 10 additions & 0 deletions payroll/models/hr_leave_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (C) 2022 Trevi Software (https://trevi.et)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class HrLeaveType(models.Model):
_inherit = "hr.leave.type"

code = fields.Char(string="Payroll Code")
22 changes: 9 additions & 13 deletions payroll/models/hr_payslip.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,13 @@ class HrPayslip(models.Model):
states={"draft": [("readonly", False)]},
)
date_from = fields.Date(
string="Date From",
readonly=True,
required=True,
default=lambda self: fields.Date.to_string(date.today().replace(day=1)),
states={"draft": [("readonly", False)]},
tracking=True,
)
date_to = fields.Date(
string="Date To",
readonly=True,
required=True,
default=lambda self: fields.Date.to_string(
Expand Down Expand Up @@ -144,10 +142,8 @@ class HrPayslip(models.Model):
dynamic_filtered_payslip_lines = fields.One2many(
"hr.payslip.line",
compute="_compute_dynamic_filtered_payslip_lines",
string="Dynamic Filtered Payslip Lines",
)
credit_note = fields.Boolean(
string="Credit Note",
readonly=True,
states={"draft": [("readonly", False)]},
help="Indicates this payslip has a refund of another",
Expand All @@ -163,11 +159,11 @@ class HrPayslip(models.Model):
payslip_count = fields.Integer(
compute="_compute_payslip_count", string="Payslip Computation Details"
)
hide_child_lines = fields.Boolean(string="Hide Child Lines", default=False)
hide_child_lines = fields.Boolean(default=False)
hide_invisible_lines = fields.Boolean(
string="Show only lines that appear on payslip", default=False
)
compute_date = fields.Date("Compute Date")
compute_date = fields.Date()
refunded_id = fields.Many2one(
"hr.payslip", string="Refunded Payslip", readonly=True
)
Expand Down Expand Up @@ -384,7 +380,7 @@ def _compute_worked_days(self, contract, day_from, day_to):
of the payslip. This returns the FULL work days expected for the resource
calendar selected for the employee (it don't substract leaves by default).
"""
work_data = contract.employee_id._get_work_days_data(
work_data = contract.employee_id._get_work_days_data_batch(
day_from,
day_to,
calendar=contract.resource_calendar_id,
Expand All @@ -394,8 +390,8 @@ def _compute_worked_days(self, contract, day_from, day_to):
"name": _("Normal Working Days paid at 100%"),
"sequence": 1,
"code": "WORK100",
"number_of_days": work_data["days"],
"number_of_hours": work_data["hours"],
"number_of_days": work_data[contract.employee_id.id]["days"],
"number_of_hours": work_data[contract.employee_id.id]["hours"],
"contract_id": contract.id,
}

Expand Down Expand Up @@ -776,16 +772,16 @@ def onchange_employee(self):

def _compute_name(self):
for record in self:
record.name = _("Salary Slip of %s for %s") % (
record.employee_id.name,
tools.ustr(
record.name = _("Salary Slip of %(name)s for %(dt)s") % {
"name": record.employee_id.name,
"dt": tools.ustr(
babel.dates.format_date(
date=datetime.combine(record.date_from, time.min),
format="MMMM-y",
locale=record.env.context.get("lang") or "en_US",
)
),
)
}

@api.onchange("contract_id")
def onchange_contract(self):
Expand Down
1 change: 0 additions & 1 deletion payroll/models/hr_payslip_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class HrPayslipLine(models.Model):
quantity = fields.Float(digits="Payroll", default=1.0)
total = fields.Float(
compute="_compute_total",
string="Total",
digits="Payroll",
store=True,
)
Expand Down
1 change: 0 additions & 1 deletion payroll/models/hr_payslip_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class HrPayslipRun(models.Model):
+ relativedelta(months=+1, day=1, days=-1),
)
credit_note = fields.Boolean(
string="Credit Note",
readonly=True,
states={"draft": [("readonly", False)]},
help="If its checked, indicates that all payslips generated from here "
Expand Down
54 changes: 34 additions & 20 deletions payroll/models/hr_salary_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,14 @@ def _compute_rule_fix(self, localdict):
"rate": 100.0,
"amount": self.amount_fix,
}
except Exception:
except Exception as ex:
raise UserError(
_("Wrong quantity defined for salary rule %s (%s) for employee %s.")
% (self.name, self.code, localdict["employee"].name)
)
_(
"Wrong quantity defined for salary rule "
"%(nm)s (%(code)s) for employee %(ee)s."
)
% {"nm": self.name, "code": self.code, "ee": localdict["employee"].name}
) from ex

def _compute_rule_percentage(self, localdict):
try:
Expand All @@ -233,14 +236,14 @@ def _compute_rule_percentage(self, localdict):
"rate": self.amount_percentage,
"amount": float(safe_eval(self.amount_percentage_base, localdict)),
}
except Exception:
except Exception as ex:
raise UserError(
_(
"Wrong percentage base or quantity defined for salary "
"rule %s (%s) for employee %s."
"rule %(nm)s (%(code)s) for employee %(ee)s."
)
% (self.name, self.code, localdict["employee"].name)
)
% {"nm": self.name, "code": self.code, "ee": localdict["employee"].name}
) from ex

def _compute_rule_code(self, localdict):
try:
Expand All @@ -250,14 +253,19 @@ def _compute_rule_code(self, localdict):
raise UserError(
_(
"""
Wrong python code defined for salary rule %s (%s) for employee %s.
Wrong python code defined for salary rule %(nm)s (%(code)s) for employee %(ee)s.
Here is the error received:
%s
%(err)s
"""
)
% (self.name, self.code, localdict["employee"].name, repr(ex))
)
% {
"nm": self.name,
"code": self.code,
"ee": localdict["employee"].name,
"err": repr(ex),
}
) from ex

def _get_rule_dict(self, localdict):
name = localdict.get("result_name") or self.name
Expand Down Expand Up @@ -293,13 +301,14 @@ def _satisfy_condition_range(self, localdict):
return (
self.condition_range_min <= result <= self.condition_range_max or False
)
except Exception:
except Exception as ex:
raise UserError(
_(
"Wrong range condition defined for salary rule %s (%s) for employee %s."
"Wrong range condition defined for salary rule "
"%(nm)s (%(code)s) for employee %(ee)s."
)
% (self.name, self.code, localdict["employee"].name)
)
% {"nm": self.name, "code": self.code, "ee": localdict["employee"].name}
) from ex

def _satisfy_condition_python(self, localdict):
try:
Expand All @@ -309,11 +318,16 @@ def _satisfy_condition_python(self, localdict):
raise UserError(
_(
"""
Wrong python condition defined for salary rule %s (%s) for employee %s.
Wrong python condition defined for salary rule %(nm)s (%(code)s) for employee %(ee)s.
Here is the error received:
%s
%(err)s
"""
)
% (self.name, self.code, localdict["employee"].name, repr(ex))
)
% {
"nm": self.name,
"code": self.code,
"ee": localdict["employee"].name,
"err": repr(ex),
}
) from ex
Loading

0 comments on commit b3970c1

Please sign in to comment.