Skip to content

Commit

Permalink
[17.0][MIG] payroll: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FernandoRomera committed Dec 22, 2023
1 parent 7a96ef4 commit 0c15e1f
Show file tree
Hide file tree
Showing 24 changed files with 103 additions and 135 deletions.
12 changes: 6 additions & 6 deletions payroll/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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|
Expand All @@ -43,7 +43,7 @@ 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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/payroll/issues/new?body=module:%20payroll%0Aversion:%2016.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:%2017.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 @@ -88,6 +88,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/16.0/payroll>`_ project on GitHub.
This module is part of the `OCA/payroll <https://github.com/OCA/payroll/tree/17.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": "16.0.1.1.0",
"version": "17.0.1.0.0",
"category": "Payroll",
"website": "https://github.com/OCA/payroll",
"sequence": 38,
Expand Down
2 changes: 1 addition & 1 deletion payroll/models/base_browsable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion payroll/models/hr_payroll_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
14 changes: 1 addition & 13 deletions payroll/models/hr_payslip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -95,57 +92,49 @@ class HrPayslip(models.Model):
"slip_id",
string="Payslip Lines",
readonly=True,
states={"draft": [("readonly", False)]},
)
company_id = fields.Many2one(
"res.company",
string="Company",
readonly=True,
copy=False,
default=lambda self: self.env.company,
states={"draft": [("readonly", False)]},
)
worked_days_line_ids = fields.One2many(
"hr.payslip.worked_days",
"payslip_id",
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(
"hr.contract",
string="Contract",
readonly=True,
tracking=True,
states={"draft": [("readonly", False)]},
)
dynamic_filtered_payslip_lines = fields.One2many(
"hr.payslip.line",
compute="_compute_dynamic_filtered_payslip_lines",
)
credit_note = fields.Boolean(
readonly=True,
states={"draft": [("readonly", False)]},
help="Indicates this payslip has a refund of another",
)
payslip_run_id = fields.Many2one(
Expand All @@ -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"
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 5 additions & 4 deletions payroll/models/hr_payslip_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
7 changes: 1 addition & 6 deletions payroll/models/hr_payslip_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")],
Expand All @@ -41,28 +40,24 @@ 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.",
)
struct_id = fields.Many2one(
"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 "
Expand Down
4 changes: 2 additions & 2 deletions payroll/models/hr_salary_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions payroll/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
8 changes: 4 additions & 4 deletions payroll/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ <h1 class="title">Payroll</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:706eec2567f796489027660b9a221865aee1332ce603aaeebfefafcc412d994c
!! source digest: sha256:def4f708faf4767d5767c515426c572391d63f2a30ffde152f86d3a019c0b920
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/payroll/tree/16.0/payroll"><img alt="OCA/payroll" src="https://img.shields.io/badge/github-OCA%2Fpayroll-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/payroll-16-0/payroll-16-0-payroll"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/payroll&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/payroll/tree/17.0/payroll"><img alt="OCA/payroll" src="https://img.shields.io/badge/github-OCA%2Fpayroll-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/payroll-17-0/payroll-17-0-payroll"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/payroll&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Manage your employee payroll records.</p>
<p>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.</p>
<p><strong>Table of contents</strong></p>
Expand All @@ -389,7 +389,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/payroll/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/payroll/issues/new?body=module:%20payroll%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/payroll/issues/new?body=module:%20payroll%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -419,7 +419,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/appstogrow"><img alt="appstogrow" src="https://github.com/appstogrow.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/nimarosa"><img alt="nimarosa" src="https://github.com/nimarosa.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/payroll/tree/16.0/payroll">OCA/payroll</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/payroll/tree/17.0/payroll">OCA/payroll</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion payroll/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class TestPayslipBase(TransactionCase):
def setUp(self):
super(TestPayslipBase, self).setUp()
super().setUp()

self.CalendarAttendance = self.env["resource.calendar.attendance"]
self.Contract = self.env["hr.contract"]
Expand Down
2 changes: 0 additions & 2 deletions payroll/tests/test_browsable_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def setUp(self):
super().setUp()

def test_init(self):

obj = BrowsableObject(self.richard_emp.id, {"test": 1}, self.env)

self.assertEqual(obj.test, 1, "Simple initialization")
Expand Down Expand Up @@ -51,7 +50,6 @@ def test_init(self):
)

def test_update_attribute(self):

obj = BrowsableObject(
self.richard_emp.id,
{
Expand Down
2 changes: 1 addition & 1 deletion payroll/tests/test_hr_payroll_cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class TestHrPayrollCancel(common.TransactionCase):
def setUp(self):
super(TestHrPayrollCancel, self).setUp()
super().setUp()
# Set system parameter
self.env["ir.config_parameter"].sudo().set_param(
"payroll.allow_cancel_payslips", True
Expand Down
2 changes: 1 addition & 1 deletion payroll/tests/test_hr_payslip_change_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class TestHrPayslipChangeState(TestHrPayrollCancel):
def setUp(self):
super(TestHrPayslipChangeState, self).setUp()
super().setUp()
self.tested_model = self.env["hr.payslip.change.state"]

def test_change_state(self):
Expand Down
3 changes: 0 additions & 3 deletions payroll/tests/test_hr_payslip_worked_days.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def setUp(self):
)

def _common_contract_leave_setup(self):

self.richard_emp.resource_id.calendar_id = self.full_calendar
self.richard_emp.contract_ids.resource_calendar_id = self.full_calendar

Expand All @@ -74,7 +73,6 @@ def _common_contract_leave_setup(self):
)

def test_worked_days_negative(self):

self._common_contract_leave_setup()

# Set system parameter
Expand Down Expand Up @@ -107,7 +105,6 @@ def test_worked_days_negative(self):
)

def test_leaves_positive(self):

self._common_contract_leave_setup()

# Set system parameter
Expand Down
Loading

0 comments on commit 0c15e1f

Please sign in to comment.