-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] Allow companies to group payslips in accounting entries
- Loading branch information
Showing
10 changed files
with
183 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from . import hr_payroll_account | ||
from . import res_config_settings | ||
from . import company |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResCompany(models.Model): | ||
_inherit = "res.company" | ||
|
||
action_group_payslips = fields.Boolean( | ||
string="Group payslips in accounting", | ||
help="Allow companies to group payslips in accounting", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
action_group_payslips = fields.Boolean( | ||
string="Group payslips in accounting", | ||
related="company_id.action_group_payslips", | ||
help="Allow companies to group payslips in accounting", | ||
readonly=False, | ||
store=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="res_config_settings_view_form" model="ir.ui.view"> | ||
<field | ||
name="name" | ||
>res.config.settings.view.form.inherit.hr.payroll.account</field> | ||
<field name="model">res.config.settings</field> | ||
<field name="inherit_id" ref="payroll.res_config_settings_view_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//div[@id='payroll_accountant']" position="after"> | ||
<div class="row mt16 o_settings_container" id="action_group_payslips"> | ||
<div class="col-lg-6 col-12 o_setting_box"> | ||
<div class="o_setting_left_pane"> | ||
<field name="action_group_payslips" /> | ||
</div> | ||
<div class="o_setting_right_pane"> | ||
<label | ||
for="action_group_payslips" | ||
string="Group payslips in accounting" | ||
/> | ||
<div class="text-muted"> | ||
Allow companies to group payslips in accounting | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from . import hr_payroll_payslips_by_employees | ||
from . import hr_payslip_change_state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import models | ||
from odoo.exceptions import UserError | ||
from odoo.tools.translate import _ | ||
|
||
|
||
class HrPayslipChangeState(models.TransientModel): | ||
|
||
_inherit = "hr.payslip.change.state" | ||
|
||
def change_state_confirm(self): | ||
company_id = self.env.company.id | ||
config_settings = self.env["res.config.settings"].search( | ||
[("company_id", "=", company_id)], limit=1 | ||
) | ||
action_group_payslips = config_settings.action_group_payslips | ||
|
||
if action_group_payslips and self.state == "done": | ||
record_ids = self.env.context.get("active_ids", False) | ||
payslip_obj = self.env["hr.payslip"] | ||
records = payslip_obj.browse(record_ids) | ||
for rec in records: | ||
if rec.state not in ("verify", "draft"): | ||
raise UserError( | ||
_( | ||
"Only payslips in states verify or draft" | ||
" can be confirmed, the payslip %(nm)s is in " | ||
"%(st)s state" | ||
) | ||
% {"nm": rec.name, "st": rec.state} | ||
) | ||
records.action_payslip_done() | ||
else: | ||
return super(HrPayslipChangeState, self).change_state_confirm() |