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/demo/hr_payroll_demo.xml b/payroll/demo/hr_payroll_demo.xml index 4e987a1a..a5cdc887 100644 --- a/payroll/demo/hr_payroll_demo.xml +++ b/payroll/demo/hr_payroll_demo.xml @@ -192,7 +192,6 @@ ref('hr_salary_rule_convanceallowance1'),ref('hr_salary_rule_professionaltax1'), Roger Scott - Building 1, Second Floor +3282823500 1: raise UserError( - _("Recursion error. Only one line should be parent of %s") - % line.parent_rule_id.name + _("Recursion error. Only one line should be parent of %(name)s") + % {"name": line.parent_rule_id.name} ) line.parent_line_id = ( parent_line[0].id if len(parent_line) == 1 else False 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/models/hr_salary_rule.py b/payroll/models/hr_salary_rule.py index a360d595..c46543d3 100644 --- a/payroll/models/hr_salary_rule.py +++ b/payroll/models/hr_salary_rule.py @@ -206,11 +206,11 @@ 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).") - % (self.name, self.code) - ) + _("Wrong quantity defined for salary rule %(name)s (%(code)s).") + % {"name": self.name, "code": self.code} + ) from ex def _compute_rule_percentage(self, localdict): try: @@ -220,14 +220,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)." + "rule %(name)s (%(code)s)." ) - % (self.name, self.code) - ) + % {"name": self.name, "code": self.code} + ) from ex def _compute_rule_code(self, localdict): try: @@ -237,14 +237,14 @@ def _compute_rule_code(self, localdict): raise UserError( _( """ -Wrong python code defined for salary rule %s (%s). +Wrong python code defined for salary rule %(name)s (%(code)s). Here is the error received: -%s +%(err)s """ ) - % (self.name, self.code, repr(ex)) - ) + % {"name": self.name, "code": self.code, "err": repr(ex)} + ) from ex def _get_rule_dict(self, localdict): name = localdict.get("result_name") or self.name @@ -276,11 +276,11 @@ 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).") - % (self.name, self.code) - ) + _("Wrong range condition defined for salary rule %(name)s (%(code)s).") + % {"name": self.name, "code": self.code} + ) from ex def _satisfy_condition_python(self, localdict): try: @@ -290,11 +290,11 @@ def _satisfy_condition_python(self, localdict): raise UserError( _( """ -Wrong python condition defined for salary rule %s (%s). +Wrong python condition defined for salary rule %(name)s (%(code)s). Here is the error received: -%s +%(err)s """ ) - % (self.name, self.code, repr(ex)) - ) + % {"name": self.name, "code": self.code, "err": repr(ex)} + ) from ex 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/common.py b/payroll/tests/common.py index 7cfb495d..ffe173bc 100644 --- a/payroll/tests/common.py +++ b/payroll/tests/common.py @@ -11,6 +11,7 @@ def setUp(self): self.CalendarAttendance = self.env["resource.calendar.attendance"] self.Contract = self.env["hr.contract"] + self.ContributionRegister = self.env["hr.contribution.register"] self.Department = self.env["hr.department"] self.PayrollStructure = self.env["hr.payroll.structure"] self.Payslip = self.env["hr.payslip"] @@ -177,6 +178,12 @@ def setUp(self): } ) + # Contribution Registers + # + self.register_hra = self.ContributionRegister.create( + {"name": "House Rent Allowance"} + ) + # I create a new employee "Richard" self.richard_emp = self.env["hr.employee"].create( { diff --git a/payroll/tests/test_hr_payroll_cancel.py b/payroll/tests/test_hr_payroll_cancel.py index bbb35a14..5ad8723b 100644 --- a/payroll/tests/test_hr_payroll_cancel.py +++ b/payroll/tests/test_hr_payroll_cancel.py @@ -25,7 +25,6 @@ def setUp(self): } ) self.hr_employee_anita = self.env.ref("hr.employee_mit") - self.hr_structure_marketing_executive = self.ref("payroll.structure_001") self.hr_contract_anita = self.env.ref("hr_contract.hr_contract_mit") self.hr_payslip = self.env["hr.payslip"].create( { @@ -69,16 +68,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_hr_payslip_worked_days.py b/payroll/tests/test_hr_payslip_worked_days.py index dbb311cf..7c365b77 100644 --- a/payroll/tests/test_hr_payslip_worked_days.py +++ b/payroll/tests/test_hr_payslip_worked_days.py @@ -18,8 +18,7 @@ def setUp(self): self.holiday_type = self.LeaveType.create( { "name": "TestLeaveType", - "code": "TESTLV", - "allocation_type": "no", + "allocation_validation_type": "no", "leave_validation_type": "no_validation", } ) @@ -89,10 +88,10 @@ def test_worked_days_negative(self): worked_days_codes = richard_payslip.worked_days_line_ids.mapped("code") self.assertIn( - "TESTLV", worked_days_codes, "The leave is in the 'Worked Days' list" + "TestLeaveType", worked_days_codes, "The leave is in the 'Worked Days' list" ) wdl_ids = richard_payslip.worked_days_line_ids.filtered( - lambda x: x.code == "TESTLV" + lambda x: x.code == "TestLeaveType" ) self.assertEqual(len(wdl_ids), 1, "There is only one line matching the leave") self.assertEqual( @@ -122,10 +121,10 @@ def test_leaves_positive(self): worked_days_codes = richard_payslip.worked_days_line_ids.mapped("code") self.assertIn( - "TESTLV", worked_days_codes, "The leave is in the 'Worked Days' list" + "TestLeaveType", worked_days_codes, "The leave is in the 'Worked Days' list" ) wdl_ids = richard_payslip.worked_days_line_ids.filtered( - lambda x: x.code == "TESTLV" + lambda x: x.code == "TestLeaveType" ) self.assertEqual(len(wdl_ids), 1, "There is only one line matching the leave") self.assertEqual( diff --git a/payroll/tests/test_hr_salary_rule.py b/payroll/tests/test_hr_salary_rule.py index b04f323b..28fc598d 100644 --- a/payroll/tests/test_hr_salary_rule.py +++ b/payroll/tests/test_hr_salary_rule.py @@ -14,7 +14,7 @@ def setUp(self): { "name": "test rule", "code": "TEST", - "category_id": self.env.ref("payroll.ALW").id, + "category_id": self.categ_alw.id, "sequence": 6, "amount_select": "code", "amount_python_compute": "result = 0", diff --git a/payroll/tests/test_payslip_flow.py b/payroll/tests/test_payslip_flow.py index 18f7ed5d..e1420120 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( @@ -154,7 +154,7 @@ def test_00_payslip_flow(self): # I print the contribution register report context = { "model": "hr.contribution.register", - "active_ids": [self.ref("payroll.hr_houserent_register")], + "active_ids": [self.register_hra.id], } test_reports.try_report_action( self.env.cr, diff --git a/payroll/views/hr_contract_views.xml b/payroll/views/hr_contract_views.xml index 0be6baf9..e7802cf8 100644 --- a/payroll/views/hr_contract_views.xml +++ b/payroll/views/hr_contract_views.xml @@ -5,14 +5,12 @@ hr.contract - + + - - - 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 - +