Skip to content

Commit

Permalink
Merge PR #157 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by nimarosa
  • Loading branch information
OCA-git-bot committed May 29, 2024
2 parents 0aa6292 + 05e4dc1 commit f0e82b2
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 74 deletions.
6 changes: 5 additions & 1 deletion payroll_account/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import hr_payroll_account
from . import hr_contract
from . import hr_payslip_line
from . import hr_payslip_run
from . import hr_payslip
from . import hr_salary_rule
14 changes: 14 additions & 0 deletions payroll_account/models/hr_contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.


from odoo import fields, models


class HrContract(models.Model):
_inherit = "hr.contract"
_description = "Employee Contract"

analytic_account_id = fields.Many2one(
"account.analytic.account", "Analytic Account"
)
journal_id = fields.Many2one("account.journal", "Salary Journal")
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,6 @@
logger = logging.getLogger(__name__)


class HrPayslipLine(models.Model):
_inherit = "hr.payslip.line"

def _get_partner_id(self, credit_account):
"""
Get partner_id of slip line to use in account_move_line
"""
# use partner of salary rule or fallback on employee's address
register_partner_id = self.salary_rule_id.register_id.partner_id
partner_id = (
register_partner_id.id or self.slip_id.employee_id.address_home_id.id
)
if credit_account:
if (
register_partner_id
or self.salary_rule_id.account_credit.internal_type
in ("receivable", "payable")
):
return partner_id
else:
if (
register_partner_id
or self.salary_rule_id.account_debit.internal_type
in ("receivable", "payable")
):
return partner_id
return False


class HrPayslip(models.Model):
_inherit = "hr.payslip"

Expand Down Expand Up @@ -327,46 +298,3 @@ def _get_tax_details(self, line):
)

return tax_ids, tax_tag_ids, tax_repartition_line_id


class HrSalaryRule(models.Model):
_inherit = "hr.salary.rule"

analytic_account_id = fields.Many2one(
"account.analytic.account", "Analytic Account"
)
account_tax_id = fields.Many2one("account.tax", "Tax")
account_debit = fields.Many2one(
"account.account", "Debit Account", domain=[("deprecated", "=", False)]
)
account_credit = fields.Many2one(
"account.account", "Credit Account", domain=[("deprecated", "=", False)]
)

tax_base_id = fields.Many2one("hr.salary.rule", "Base")
tax_line_ids = fields.One2many("hr.salary.rule", "tax_base_id", string="Tax lines")


class HrContract(models.Model):
_inherit = "hr.contract"
_description = "Employee Contract"

analytic_account_id = fields.Many2one(
"account.analytic.account", "Analytic Account"
)
journal_id = fields.Many2one("account.journal", "Salary Journal")


class HrPayslipRun(models.Model):
_inherit = "hr.payslip.run"

journal_id = fields.Many2one(
"account.journal",
"Salary Journal",
states={"draft": [("readonly", False)]},
readonly=True,
required=True,
default=lambda self: self.env["account.journal"].search(
[("type", "=", "general")], limit=1
),
)
33 changes: 33 additions & 0 deletions payroll_account/models/hr_payslip_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.


from odoo import models


class HrPayslipLine(models.Model):
_inherit = "hr.payslip.line"

def _get_partner_id(self, credit_account):
"""
Get partner_id of slip line to use in account_move_line
"""
# use partner of salary rule or fallback on employee's address
register_partner_id = self.salary_rule_id.register_id.partner_id
partner_id = (
register_partner_id.id or self.slip_id.employee_id.address_home_id.id
)
if credit_account:
if (
register_partner_id
or self.salary_rule_id.account_credit.internal_type
in ("receivable", "payable")
):
return partner_id
else:
if (
register_partner_id
or self.salary_rule_id.account_debit.internal_type
in ("receivable", "payable")
):
return partner_id
return False
19 changes: 19 additions & 0 deletions payroll_account/models/hr_payslip_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.


from odoo import fields, models


class HrPayslipRun(models.Model):
_inherit = "hr.payslip.run"

journal_id = fields.Many2one(
"account.journal",
"Salary Journal",
states={"draft": [("readonly", False)]},
readonly=True,
required=True,
default=lambda self: self.env["account.journal"].search(
[("type", "=", "general")], limit=1
),
)
34 changes: 34 additions & 0 deletions payroll_account/models/hr_salary_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.


from odoo import fields, models


class HrSalaryRule(models.Model):
_inherit = "hr.salary.rule"

company_id = fields.Many2one(
"res.company",
string="Company",
required=True,
default=lambda self: self.env.company,
)
analytic_account_id = fields.Many2one(
"account.analytic.account", "Analytic Account"
)
account_tax_id = fields.Many2one("account.tax", "Tax")
account_debit = fields.Many2one(
"account.account",
"Debit Account",
domain=[("deprecated", "=", False)],
company_dependent=True,
)
account_credit = fields.Many2one(
"account.account",
"Credit Account",
domain=[("deprecated", "=", False)],
company_dependent=True,
)

tax_base_id = fields.Many2one("hr.salary.rule", "Base")
tax_line_ids = fields.One2many("hr.salary.rule", "tax_base_id", string="Tax lines")
2 changes: 1 addition & 1 deletion payroll_account/tests/test_payroll_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class TestPayrollAccount(common.TransactionCase):
def setUp(self):
super(TestPayrollAccount, self).setUp()
super().setUp()

# Activate company currency
self.env.user.company_id.currency_id.active = True
Expand Down

0 comments on commit f0e82b2

Please sign in to comment.