Commit c459bf54 authored by Santiago Apel's avatar Santiago Apel 💬
Browse files

Merge branch 'last_contract_id' into '12.0-stage'

[IMP] ADD BIGENT CONTRACT

See merge request !32
parents d554babc 2298ee1b
......@@ -33,6 +33,7 @@
"security/ir.model.access.csv",
"views/hr_payroll_base_config_view.xml",
"views/hr_payslip_view.xml",
'views/hr_employee_views.xml',
"views/hr_payslip_line_view.xml",
"views/hr_payslip_run_view.xml",
"views/hr_salary_rule_view.xml",
......
......@@ -13,4 +13,5 @@ from . import safe_eval # noqa
from . import res_company # noqa
from . import hr_contract # noqa
from . import hr_payroll_structure # added struct_type field - 6-abr (dan)
from . import hr_payroll_structure_type # created struct_type model - 6-abr (dan)
\ No newline at end of file
from . import hr_payroll_structure_type # created struct_type model - 6-abr (dan)
from . import hr_employee
\ No newline at end of file
# -*- coding: utf-8 -*-
from odoo import api, fields, models
class HREmployee(models.Model):
_inherit = "hr.employee"
@api.depends('contract_ids','contract_ids.state','contract_ids.date_start','contract_ids.date_end')
def _get_vigent_contract(self):
for record in self:
contract_ids = self.env["hr.contract"].search(
['&',("employee_id", "=", record.id),('state','=','open')],
order="date_start desc",
limit=1,
)
if contract_ids:
contract_id = contract_ids[0]
record.last_contract_id = contract_id.id
else:
record.last_contract_id = False
last_contract_id = fields.Many2one(
"hr.contract",
string="Vigent contract",
compute=_get_vigent_contract,
store=True,
)
<odoo>
<data>
<record id="view_employee_form_inherit_lsd" model="ir.ui.view">
<field name="name">view.employee.form.inherit.lsd</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='other_id']" position="after">
<field name="last_contract_id"/>
</xpath>
</data>
</field>
</record>
</data>
</odoo>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment