From 0c15e1f7eef9f91da27538d6562d9fc49478d9d9 Mon Sep 17 00:00:00 2001
From: FernandoRomera
Date: Thu, 21 Dec 2023 08:44:13 +0100
Subject: [PATCH] [17.0][MIG] payroll: Migration to 17.0
---
payroll/README.rst | 12 +++---
payroll/__manifest__.py | 2 +-
payroll/models/base_browsable.py | 2 +-
payroll/models/hr_payroll_structure.py | 2 +-
payroll/models/hr_payslip.py | 14 +------
payroll/models/hr_payslip_line.py | 9 ++--
payroll/models/hr_payslip_run.py | 7 +---
payroll/models/hr_salary_rule.py | 4 +-
payroll/pyproject.toml | 3 ++
payroll/static/description/index.html | 8 ++--
payroll/tests/common.py | 2 +-
payroll/tests/test_browsable_object.py | 2 -
payroll/tests/test_hr_payroll_cancel.py | 2 +-
payroll/tests/test_hr_payslip_change_state.py | 2 +-
payroll/tests/test_hr_payslip_worked_days.py | 3 --
payroll/tests/test_hr_salary_rule.py | 28 ++++++++-----
payroll/tests/test_payslip_flow.py | 22 +++-------
payroll/views/hr_payroll_structure_views.xml | 5 +--
payroll/views/hr_payslip_line_views.xml | 19 +++------
payroll/views/hr_payslip_run_views.xml | 10 +++--
payroll/views/hr_payslip_views.xml | 32 +++++++-------
.../views/hr_salary_rule_category_views.xml | 5 +--
payroll/views/hr_salary_rule_views.xml | 42 +++++++++++--------
payroll/wizard/hr_payslip_change_state.py | 1 -
24 files changed, 103 insertions(+), 135 deletions(-)
create mode 100644 payroll/pyproject.toml
diff --git a/payroll/README.rst b/payroll/README.rst
index 088a19ea..9a868d87 100644
--- a/payroll/README.rst
+++ b/payroll/README.rst
@@ -7,7 +7,7 @@ Payroll
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- !! source digest: sha256:706eec2567f796489027660b9a221865aee1332ce603aaeebfefafcc412d994c
+ !! source digest: sha256:def4f708faf4767d5767c515426c572391d63f2a30ffde152f86d3a019c0b920
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,13 +17,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/16.0/payroll
+ :target: https://github.com/OCA/payroll/tree/17.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-16-0/payroll-16-0-payroll
+ :target: https://translation.odoo-community.org/projects/payroll-17-0/payroll-17-0-payroll
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
- :target: https://runboat.odoo-community.org/builds?repo=OCA/payroll&target_branch=16.0
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/payroll&target_branch=17.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -43,7 +43,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -88,6 +88,6 @@ Current `maintainers `__:
|maintainer-appstogrow| |maintainer-nimarosa|
-This module is part of the `OCA/payroll `_ project on GitHub.
+This module is part of the `OCA/payroll `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/payroll/__manifest__.py b/payroll/__manifest__.py
index 76008e49..b23f35e7 100644
--- a/payroll/__manifest__.py
+++ b/payroll/__manifest__.py
@@ -2,7 +2,7 @@
{
"name": "Payroll",
- "version": "16.0.1.1.0",
+ "version": "17.0.1.0.0",
"category": "Payroll",
"website": "https://github.com/OCA/payroll",
"sequence": 38,
diff --git a/payroll/models/base_browsable.py b/payroll/models/base_browsable.py
index 58333ce8..249b04b3 100644
--- a/payroll/models/base_browsable.py
+++ b/payroll/models/base_browsable.py
@@ -7,7 +7,7 @@
_logger = logging.getLogger(__name__)
-class BaseBrowsableObject(object):
+class BaseBrowsableObject:
def __init__(self, vals_dict):
self.__dict__["base_fields"] = ["base_fields", "dict"]
self.dict = vals_dict
diff --git a/payroll/models/hr_payroll_structure.py b/payroll/models/hr_payroll_structure.py
index 6ccbf11a..f5d9d6d9 100644
--- a/payroll/models/hr_payroll_structure.py
+++ b/payroll/models/hr_payroll_structure.py
@@ -66,7 +66,7 @@ def _check_parent_id(self):
def copy(self, default=None):
self.ensure_one()
default = dict(default or {}, code=_("%s (copy)") % self.code)
- return super(HrPayrollStructure, self).copy(default)
+ return super().copy(default)
def get_all_rules(self):
"""
diff --git a/payroll/models/hr_payslip.py b/payroll/models/hr_payslip.py
index 6a0e6a7f..f2c2b0ca 100644
--- a/payroll/models/hr_payslip.py
+++ b/payroll/models/hr_payslip.py
@@ -54,13 +54,11 @@ class HrPayslip(models.Model):
string="Employee",
required=True,
readonly=True,
- states={"draft": [("readonly", False)]},
)
date_from = fields.Date(
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(
@@ -69,7 +67,6 @@ class HrPayslip(models.Model):
default=lambda self: fields.Date.to_string(
(datetime.now() + relativedelta(months=+1, day=1, days=-1)).date()
),
- states={"draft": [("readonly", False)]},
tracking=True,
)
state = fields.Selection(
@@ -95,7 +92,6 @@ class HrPayslip(models.Model):
"slip_id",
string="Payslip Lines",
readonly=True,
- states={"draft": [("readonly", False)]},
)
company_id = fields.Many2one(
"res.company",
@@ -103,7 +99,6 @@ class HrPayslip(models.Model):
readonly=True,
copy=False,
default=lambda self: self.env.company,
- states={"draft": [("readonly", False)]},
)
worked_days_line_ids = fields.One2many(
"hr.payslip.worked_days",
@@ -111,25 +106,21 @@ class HrPayslip(models.Model):
string="Payslip Worked Days",
copy=True,
readonly=True,
- states={"draft": [("readonly", False)]},
)
input_line_ids = fields.One2many(
"hr.payslip.input",
"payslip_id",
string="Payslip Inputs",
readonly=True,
- states={"draft": [("readonly", False)]},
)
paid = fields.Boolean(
string="Made Payment Order ? ",
readonly=True,
copy=False,
- states={"draft": [("readonly", False)]},
)
note = fields.Text(
string="Internal Note",
readonly=True,
- states={"draft": [("readonly", False)]},
tracking=True,
)
contract_id = fields.Many2one(
@@ -137,7 +128,6 @@ class HrPayslip(models.Model):
string="Contract",
readonly=True,
tracking=True,
- states={"draft": [("readonly", False)]},
)
dynamic_filtered_payslip_lines = fields.One2many(
"hr.payslip.line",
@@ -145,7 +135,6 @@ class HrPayslip(models.Model):
)
credit_note = fields.Boolean(
readonly=True,
- states={"draft": [("readonly", False)]},
help="Indicates this payslip has a refund of another",
)
payslip_run_id = fields.Many2one(
@@ -154,7 +143,6 @@ class HrPayslip(models.Model):
readonly=True,
copy=False,
tracking=True,
- states={"draft": [("readonly", False)]},
)
payslip_count = fields.Integer(
compute="_compute_payslip_count", string="Payslip Computation Details"
@@ -279,7 +267,7 @@ def unlink(self):
raise UserError(
_("You cannot delete a payslip which is not draft or cancelled")
)
- return super(HrPayslip, self).unlink()
+ return super().unlink()
def compute_sheet(self):
for payslip in self:
diff --git a/payroll/models/hr_payslip_line.py b/payroll/models/hr_payslip_line.py
index e56562d6..379a4ce7 100644
--- a/payroll/models/hr_payslip_line.py
+++ b/payroll/models/hr_payslip_line.py
@@ -55,9 +55,10 @@ def _compute_parent_line_id(self):
for line in self:
if line.parent_rule_id:
parent_line = line.slip_id.line_ids.filtered(
- lambda l: l.salary_rule_id == line.parent_rule_id
- and l.contract_id == line.contract_id
- and l.slip_id == line.slip_id
+ lambda record, line=line: record.salary_rule_id
+ == line.parent_rule_id
+ and record.contract_id == line.contract_id
+ and record.slip_id == line.slip_id
)
if parent_line and len(parent_line) > 1:
raise UserError(
@@ -92,4 +93,4 @@ def create(self, vals_list):
raise UserError(
_("You must set a contract to create a payslip line.")
)
- return super(HrPayslipLine, self).create(vals_list)
+ return super().create(vals_list)
diff --git a/payroll/models/hr_payslip_run.py b/payroll/models/hr_payslip_run.py
index cf77c2a0..b6ee18ba 100644
--- a/payroll/models/hr_payslip_run.py
+++ b/payroll/models/hr_payslip_run.py
@@ -12,14 +12,13 @@ class HrPayslipRun(models.Model):
_order = "id desc"
name = fields.Char(
- required=True, readonly=True, states={"draft": [("readonly", False)]}
+ required=True, readonly=True
)
slip_ids = fields.One2many(
"hr.payslip",
"payslip_run_id",
string="Payslips",
readonly=True,
- states={"draft": [("readonly", False)]},
)
state = fields.Selection(
[("draft", "Draft"), ("close", "Close")],
@@ -41,20 +40,17 @@ class HrPayslipRun(models.Model):
string="Date From",
required=True,
readonly=True,
- states={"draft": [("readonly", False)]},
default=lambda self: fields.Date.today().replace(day=1),
)
date_end = fields.Date(
string="Date To",
required=True,
readonly=True,
- states={"draft": [("readonly", False)]},
default=lambda self: fields.Date.today().replace(day=1)
+ relativedelta(months=+1, day=1, days=-1),
)
credit_note = fields.Boolean(
readonly=True,
- states={"draft": [("readonly", False)]},
help="If its checked, indicates that all payslips generated from here "
"are refund payslips.",
)
@@ -62,7 +58,6 @@ class HrPayslipRun(models.Model):
"hr.payroll.structure",
string="Structure",
readonly=True,
- states={"draft": [("readonly", False)]},
help="Defines the rules that have to be applied to this payslip batch, "
"accordingly to the contract chosen. If you let empty the field "
"contract, this field isn't mandatory anymore and thus the rules "
diff --git a/payroll/models/hr_salary_rule.py b/payroll/models/hr_salary_rule.py
index 19559d55..be94a40e 100644
--- a/payroll/models/hr_salary_rule.py
+++ b/payroll/models/hr_salary_rule.py
@@ -208,7 +208,7 @@ def _compute_rule(self, localdict):
:rtype: {"name": string, "quantity": float, "rate": float, "amount": float}
"""
self.ensure_one()
- method = "_compute_rule_{}".format(self.amount_select)
+ method = f"_compute_rule_{self.amount_select}"
return api.call_kw(self, method, [self.ids, localdict], {})
def _compute_rule_fix(self, localdict):
@@ -285,7 +285,7 @@ def _satisfy_condition(self, localdict):
given contract. Return False otherwise.
"""
self.ensure_one()
- method = "_satisfy_condition_{}".format(self.condition_select)
+ method = f"_satisfy_condition_{self.condition_select}"
if self.parent_rule_id:
current_result = api.call_kw(self, method, [self.ids, localdict], {})
parent_result = self.parent_rule_id._satisfy_condition(localdict)
diff --git a/payroll/pyproject.toml b/payroll/pyproject.toml
new file mode 100644
index 00000000..4231d0cc
--- /dev/null
+++ b/payroll/pyproject.toml
@@ -0,0 +1,3 @@
+[build-system]
+requires = ["whool"]
+build-backend = "whool.buildapi"
diff --git a/payroll/static/description/index.html b/payroll/static/description/index.html
index 2926bcaf..4a2eb965 100644
--- a/payroll/static/description/index.html
+++ b/payroll/static/description/index.html
@@ -367,9 +367,9 @@
Payroll
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!! source digest: sha256:706eec2567f796489027660b9a221865aee1332ce603aaeebfefafcc412d994c
+!! source digest: sha256:def4f708faf4767d5767c515426c572391d63f2a30ffde152f86d3a019c0b920
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
Manage your employee payroll records.
This module is a backport from Odoo SA and as such, it is not included in the OCA CLA. That means we do not have a copy of the copyright on it like all other OCA modules.
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
-feedback.