Block salary letters for archived employees
This commit is contained in:
parent
e7f58c33f3
commit
11dd9b3395
@ -1,4 +1,5 @@
|
||||
from odoo import fields, models
|
||||
from odoo import _, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class HrContract(models.Model):
|
||||
@ -22,10 +23,32 @@ class HrContract(models.Model):
|
||||
string="Letter Signed Date", tracking=True
|
||||
)
|
||||
mcs_salary_revision_notes = fields.Text(string="Salary Revision Notes")
|
||||
mcs_employee_active = fields.Boolean(
|
||||
string="Employee Active",
|
||||
related="employee_id.active",
|
||||
)
|
||||
|
||||
def action_mcs_generate_salary_revision_letter(self):
|
||||
today = fields.Date.context_today(self)
|
||||
for contract in self:
|
||||
if not contract.employee_id.active:
|
||||
raise UserError(
|
||||
_(
|
||||
"Salary revision letters cannot be generated for archived employees."
|
||||
)
|
||||
)
|
||||
if contract.state != "open":
|
||||
raise UserError(
|
||||
_(
|
||||
"Salary revision letters can only be generated for running contracts."
|
||||
)
|
||||
)
|
||||
if contract.mcs_salary_revision_state == "archived":
|
||||
raise UserError(
|
||||
_(
|
||||
"This salary revision letter is archived and cannot be generated."
|
||||
)
|
||||
)
|
||||
if contract.mcs_salary_revision_state == "draft":
|
||||
contract.write(
|
||||
{
|
||||
|
||||
@ -5,11 +5,12 @@
|
||||
<field name="inherit_id" ref="payroll.hr_contract_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//header" position="inside">
|
||||
<button name="action_mcs_generate_salary_revision_letter" type="object" string="Generate Salary Letter" class="btn-primary"/>
|
||||
<button name="action_mcs_generate_salary_revision_letter" type="object" string="Generate Salary Letter" class="btn-primary" invisible="not mcs_employee_active or state != 'open' or mcs_salary_revision_state == 'archived'"/>
|
||||
<button name="action_mcs_mark_salary_letter_signed" type="object" string="Mark Signed" invisible="mcs_salary_revision_state == 'signed'"/>
|
||||
<button name="action_mcs_archive_salary_letter" type="object" string="Archive Letter" invisible="mcs_salary_revision_state == 'archived'"/>
|
||||
</xpath>
|
||||
<xpath expr="//group[@name='salary']" position="inside">
|
||||
<field name="mcs_employee_active" invisible="1"/>
|
||||
<field name="mcs_salary_revision_state" widget="statusbar" statusbar_visible="draft,sent,signed,archived"/>
|
||||
<field name="mcs_salary_revision_sent_date"/>
|
||||
<field name="mcs_salary_revision_signed_date"/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user