From c236735113ab9940b6dfc0bf84bf37d97f08a6d6 Mon Sep 17 00:00:00 2001 From: Michael Telahun Date: Thu, 13 Oct 2022 15:03:08 +0300 Subject: [PATCH] [MIG] payroll: Migration to 15.0 --- payroll/__manifest__.py | 2 +- payroll/data/hr_payroll_data.xml | 22 ++- payroll/data/hr_payroll_sequence.xml | 16 +- payroll/models/hr_employee.py | 1 - payroll/models/hr_payslip.py | 34 ++-- payroll/models/hr_payslip_line.py | 1 - payroll/models/hr_payslip_run.py | 1 - payroll/models/hr_rule_parameter.py | 7 +- payroll/security/hr_payroll_security.xml | 168 +++++++++--------- payroll/tests/test_hr_payroll_cancel.py | 20 +-- payroll/tests/test_hr_payslip_change_state.py | 5 +- payroll/tests/test_payslip_flow.py | 20 +-- .../views/hr_contribution_register_views.xml | 2 +- payroll/views/hr_payroll_structure_views.xml | 4 +- payroll/views/hr_payslip_line_views.xml | 9 +- payroll/views/hr_payslip_run_views.xml | 1 - payroll/views/hr_payslip_views.xml | 23 +-- .../views/hr_salary_rule_category_views.xml | 2 +- payroll/views/hr_salary_rule_views.xml | 8 +- ...hr_payroll_contribution_register_report.py | 5 +- 20 files changed, 161 insertions(+), 190 deletions(-) diff --git a/payroll/__manifest__.py b/payroll/__manifest__.py index 79bebeeb..765f92df 100644 --- a/payroll/__manifest__.py +++ b/payroll/__manifest__.py @@ -2,7 +2,7 @@ { "name": "Payroll", - "version": "14.0.5.5.1", + "version": "15.0.1.0.0", "category": "Human Resources", "website": "https://github.com/OCA/payroll", "sequence": 38, diff --git a/payroll/data/hr_payroll_data.xml b/payroll/data/hr_payroll_data.xml index c3adfdd0..1984a026 100644 --- a/payroll/data/hr_payroll_data.xml +++ b/payroll/data/hr_payroll_data.xml @@ -1,14 +1,12 @@ - - - - - Payroll - 2 - - - Payroll Rate - 4 - - + + + + Payroll + 2 + + + Payroll Rate + 4 + diff --git a/payroll/data/hr_payroll_sequence.xml b/payroll/data/hr_payroll_sequence.xml index b0e75db8..ae5e10e3 100644 --- a/payroll/data/hr_payroll_sequence.xml +++ b/payroll/data/hr_payroll_sequence.xml @@ -1,11 +1,9 @@ - - - - Salary Slip - salary.slip - SLIP/ - 3 - - + + + Salary Slip + salary.slip + SLIP/ + 3 + diff --git a/payroll/models/hr_employee.py b/payroll/models/hr_employee.py index 7b23ea39..68c4497b 100644 --- a/payroll/models/hr_employee.py +++ b/payroll/models/hr_employee.py @@ -12,7 +12,6 @@ class HrEmployee(models.Model): ) payslip_count = fields.Integer( compute="_compute_payslip_count", - string="Payslip Count", groups="payroll.group_payroll_user", ) diff --git a/payroll/models/hr_payslip.py b/payroll/models/hr_payslip.py index 9e0a6380..030a04e3 100644 --- a/payroll/models/hr_payslip.py +++ b/payroll/models/hr_payslip.py @@ -57,7 +57,6 @@ 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)), @@ -65,7 +64,6 @@ class HrPayslip(models.Model): tracking=True, ) date_to = fields.Date( - string="Date To", readonly=True, required=True, default=lambda self: fields.Date.to_string( @@ -149,10 +147,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", @@ -168,16 +164,14 @@ 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) - compute_date = fields.Date("Compute Date") + hide_child_lines = fields.Boolean(default=False) + compute_date = fields.Date() refunded_id = fields.Many2one( "hr.payslip", string="Refunded Payslip", readonly=True ) - allow_cancel_payslips = fields.Boolean( - "Allow Cancel Payslips", compute="_compute_allow_cancel_payslips" - ) + allow_cancel_payslips = fields.Boolean(compute="_compute_allow_cancel_payslips") prevent_compute_on_confirm = fields.Boolean( - "Prevent Compute on Confirm", compute="_compute_prevent_compute_on_confirm" + compute="_compute_prevent_compute_on_confirm" ) def _compute_prevent_compute_on_confirm(self): @@ -780,15 +774,17 @@ 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( - babel.dates.format_date( - date=datetime.combine(record.date_from, time.min), - format="MMMM-y", - locale=record.env.context.get("lang") or "en_US", - ) - ), + record.name = _("Salary Slip of %(name)s for %(date)s") % ( + { + "name": record.employee_id.name, + "date": 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") diff --git a/payroll/models/hr_payslip_line.py b/payroll/models/hr_payslip_line.py index 3f3326ed..e56562d6 100644 --- a/payroll/models/hr_payslip_line.py +++ b/payroll/models/hr_payslip_line.py @@ -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, ) diff --git a/payroll/models/hr_payslip_run.py b/payroll/models/hr_payslip_run.py index aab8233d..f794d19d 100644 --- a/payroll/models/hr_payslip_run.py +++ b/payroll/models/hr_payslip_run.py @@ -46,7 +46,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 " diff --git a/payroll/models/hr_rule_parameter.py b/payroll/models/hr_rule_parameter.py index 28768b20..d0d00083 100644 --- a/payroll/models/hr_rule_parameter.py +++ b/payroll/models/hr_rule_parameter.py @@ -13,7 +13,7 @@ class HrSalaryRuleParameterValue(models.Model): "hr.rule.parameter", required=True, ondelete="cascade" ) code = fields.Char(related="rule_parameter_id.code", store=True, readonly=True) - date_from = fields.Date(string="Date From", required=True) + date_from = fields.Date(required=True) parameter_value = fields.Text(help="Python Code") country_id = fields.Many2one(related="rule_parameter_id.country_id") company_id = fields.Many2one(related="rule_parameter_id.company_id") @@ -33,7 +33,7 @@ class HrSalaryRuleParameter(models.Model): name = fields.Char(required=True) code = fields.Char(required=True) - description = fields.Text("Description") + description = fields.Text() country_id = fields.Many2one( "res.country", string="Country", @@ -62,7 +62,8 @@ def _get_parameter_from_code(self, code, date=None): return ast.literal_eval(rule_parameter.parameter_value) else: raise UserError( - _("No rule parameter with code '%s' was found for %s ") % (code, date) + _("No rule parameter with code '%(code)s' was found for %(date)d ") + % ({"code": code, "date": date}) ) _sql_constraints = [ diff --git a/payroll/security/hr_payroll_security.xml b/payroll/security/hr_payroll_security.xml index 2ccfdcf7..bfc327ef 100644 --- a/payroll/security/hr_payroll_security.xml +++ b/payroll/security/hr_payroll_security.xml @@ -1,87 +1,85 @@ - - - - Payroll - Manage employee payroll - 16 - - - Officer - - - - - Manager - - - - - - - - - Officer and subordinates Payslip - - - ['|','|', ('employee_id.user_id', '=', user.id), - ('employee_id.department_id', '=', False), - ('employee_id.department_id.manager_id.user_id', '=', user.id)] - - - - - All Payslip - - [(1,'=',1)] - - - - - Payslip: multi-company - - - - ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] - - - - Payroll Structure: multi-company - - - - ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] - - - - Salary Rule: multi-company - - - - ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] - - - - Salary Rule Category: multi-company - - - - ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] - - - - Contribution Register: multi-company - - - - ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] - - - + + + Payroll + Manage employee payroll + 16 + + + Officer + + + + + Manager + + + + + + + + + Officer and subordinates Payslip + + + ['|','|', ('employee_id.user_id', '=', user.id), + ('employee_id.department_id', '=', False), + ('employee_id.department_id.manager_id.user_id', '=', user.id)] + + + + + All Payslip + + [(1,'=',1)] + + + + + Payslip: multi-company + + + + ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] + + + + Payroll Structure: multi-company + + + + ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] + + + + Salary Rule: multi-company + + + + ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] + + + + Salary Rule Category: multi-company + + + + ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] + + + + Contribution Register: multi-company + + + + ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] + + diff --git a/payroll/tests/test_hr_payroll_cancel.py b/payroll/tests/test_hr_payroll_cancel.py index bbb35a14..59d0eb0e 100644 --- a/payroll/tests/test_hr_payroll_cancel.py +++ b/payroll/tests/test_hr_payroll_cancel.py @@ -69,16 +69,16 @@ def _create_payslip(self): [("payslip_id", "=", self.hr_payslip.id)] ) payslip_input.write({"amount": 5.0}) - context = { - "lang": "en_US", - "tz": False, - "active_model": "hr.payslip", - "department_id": False, - "active_ids": [self.payslip_action_id], - "section_id": False, - "active_id": self.payslip_action_id, - } - self.hr_payslip.with_context(context).compute_sheet() + self.hr_payslip.with_context( + {}, + lang="en_US", + tz=False, + active_model="hr.payslip", + department_id=False, + active_ids=[self.payslip_action_id], + section_id=False, + active_id=self.payslip_action_id, + ).compute_sheet() return self.hr_payslip def test_action_payslip_cancel(self): diff --git a/payroll/tests/test_hr_payslip_change_state.py b/payroll/tests/test_hr_payslip_change_state.py index 4176d56c..e137f22a 100644 --- a/payroll/tests/test_hr_payslip_change_state.py +++ b/payroll/tests/test_hr_payslip_change_state.py @@ -15,8 +15,9 @@ def setUp(self): def test_change_state(self): hr_payslip = self._create_payslip() tested_model = self.tested_model - context = {"active_ids": [hr_payslip.id]} - action = tested_model.with_context(context).create({"state": "verify"}) + action = tested_model.with_context(active_ids=[hr_payslip.id]).create( + {"state": "verify"} + ) # By default, a payslip is on draft state action.change_state_confirm() # trying to set it to wrong states diff --git a/payroll/tests/test_payslip_flow.py b/payroll/tests/test_payslip_flow.py index 18f7ed5d..edc2acfc 100644 --- a/payroll/tests/test_payslip_flow.py +++ b/payroll/tests/test_payslip_flow.py @@ -42,17 +42,17 @@ def test_00_payslip_flow(self): # I verify the payslip is in draft state self.assertEqual(richard_payslip.state, "draft", "State not changed!") - context = { - "lang": "en_US", - "tz": False, - "active_model": "ir.ui.menu", - "department_id": False, - "section_id": False, - "active_ids": [self.ref("payroll.hr_payslip_menu")], - "active_id": self.ref("payroll.hr_payslip_menu"), - } # I click on 'Compute Sheet' button on payslip - richard_payslip.with_context(context).compute_sheet() + richard_payslip.with_context( + {}, + lang="en_US", + tz=False, + active_model="ir.ui.menu", + department_id=False, + section_id=False, + active_ids=[self.ref("payroll.hr_payslip_menu")], + active_id=self.ref("payroll.hr_payslip_menu"), + ).compute_sheet() # Check child rules shown in table by default child_line = richard_payslip.dynamic_filtered_payslip_lines.filtered( diff --git a/payroll/views/hr_contribution_register_views.xml b/payroll/views/hr_contribution_register_views.xml index 6a11d79c..cae969bd 100644 --- a/payroll/views/hr_contribution_register_views.xml +++ b/payroll/views/hr_contribution_register_views.xml @@ -4,7 +4,7 @@ hr.contribution.register.tree hr.contribution.register - + hr.payroll.structure.tree hr.payroll.structure - + @@ -21,7 +21,7 @@ hr.payroll.structure children_ids - + hr.payslip.line.tree hr.payslip.line - + @@ -39,7 +35,7 @@ hr.payslip.line.form hr.payslip.line -
+

@@ -77,7 +73,6 @@ diff --git a/payroll/views/hr_payslip_views.xml b/payroll/views/hr_payslip_views.xml index 493f0ffb..8774f01d 100644 --- a/payroll/views/hr_payslip_views.xml +++ b/payroll/views/hr_payslip_views.xml @@ -4,12 +4,7 @@ hr.payslip.tree hr.payslip - + @@ -77,7 +72,7 @@ hr.payslip.form hr.payslip - +