Commit cc5c527b authored by Agustín Maio's avatar Agustín Maio
Browse files

Merge branch 'RR-280' into '12.0-stage'

[MOD] Antique

Closes RR-280

See merge request !36
parents e96645d7 de0b7838
......@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-07 17:08+0000\n"
"PO-Revision-Date: 2022-03-07 14:11-0300\n"
"POT-Creation-Date: 2022-04-27 15:53+0000\n"
"PO-Revision-Date: 2022-04-27 12:55-0300\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"Language: es_AR\n"
......@@ -17,6 +17,11 @@ msgstr ""
"Plural-Forms: \n"
"X-Generator: Poedit 3.0.1\n"
#. module: hr_payroll_base_config
#: selection:hr.employee,antique_method:0
msgid "Adjusted"
msgstr "Ajustada"
#. module: hr_payroll_base_config
#: model_terms:ir.ui.view,arch_db:hr_payroll_base_config.view_hr_payslip_line_filter
msgid "Amount Type"
......@@ -32,11 +37,21 @@ msgstr "Centro de costo"
msgid "Antique"
msgstr "Antigüedad"
#. module: hr_payroll_base_config
#: model:ir.model.fields,field_description:hr_payroll_base_config.field_hr_employee__antique_days
msgid "Antique Days"
msgstr "Días de antigüedad"
#. module: hr_payroll_base_config
#: model:ir.model.fields,field_description:hr_payroll_base_config.field_hr_payslip__antique_december
msgid "Antique December"
msgstr "Antigüedad a diciembre"
#. module: hr_payroll_base_config
#: model:ir.model.fields,field_description:hr_payroll_base_config.field_hr_employee__antique_method
msgid "Antique Method"
msgstr "Método de antigüedad"
#. module: hr_payroll_base_config
#: model:ir.model.fields,field_description:hr_payroll_base_config.field_hr_payslip__antique_months
msgid "Antique Months"
......@@ -96,6 +111,11 @@ msgstr "Creado el"
msgid "Date"
msgstr "Fecha"
#. module: hr_payroll_base_config
#: model_terms:ir.ui.view,arch_db:hr_payroll_base_config.view_hr_payslip_form
msgid "Days"
msgstr "Días"
#. module: hr_payroll_base_config
#: model:ir.model.fields,field_description:hr_payroll_base_config.field_hr_payroll_base_config__discount
msgid "Discount"
......@@ -323,6 +343,11 @@ msgstr "Configuración Genérica RRHH"
msgid "Re compute payslips"
msgstr "ReCalcular"
#. module: hr_payroll_base_config
#: selection:hr.employee,antique_method:0
msgid "Real"
msgstr "Real"
#. module: hr_payroll_base_config
#: model_terms:ir.ui.view,arch_db:hr_payroll_base_config.view_hr_payslip_line_tree
msgid "Rule Code"
......
......@@ -29,3 +29,10 @@ class HREmployee(models.Model):
compute=_get_vigent_contract,
store=True,
)
antique_method = fields.Selection([
('real', 'Real'),
('adjusted', 'Adjusted'),
], string='Antique Method')
antique_days = fields.Integer(string='Antique Days')
......@@ -19,7 +19,7 @@ from odoo import api, fields, models # , _, exceptions
_logger = logging.getLogger(__name__)
def _compute_antique_from_dates(date_start, date_end):
def _compute_antique_from_dates(date_start, date_end, days=False):
delta = relativedelta(date_end, date_start)
antique = 0
......@@ -29,6 +29,9 @@ def _compute_antique_from_dates(date_start, date_end):
if delta.months:
antique += delta.months
if days:
antique = (date_end - date_start).days
return antique
......@@ -323,24 +326,34 @@ class HRPayslip(models.Model):
date_to = fields.Date.from_string(payslip.date_to)
employee_id = payslip.employee_id.id
# Get oldest contract
domain = [('employee_id', '=', employee_id)]
# Get all contracts
domain = [('employee_id', '=', employee_id), ('state', 'in', ['open', 'close', 'cancel'])]
contracts = self.env['hr.contract'].search(
domain, limit=1, order='date_start ASC'
domain, order='date_start ASC'
)
if not contracts:
continue
oldest_contract_date_start = fields.Date.from_string(
contracts[0].date_start
)
if not (date_to and oldest_contract_date_start):
continue
# Compute recognized antique
antique_recognized = _compute_antique_from_dates(
oldest_contract_date_start, date_to
)
antique_recognized = 0
for contract in contracts:
contract_date_start = fields.Date.from_string(
contract.date_start
)
contract_date_end = fields.Date.from_string(
contract.date_end
) or date_to
# Check if contract.date_end is missing for a non-pending contract
if (not contract.date_end and contract.state in ['close', 'cancel']):
continue
if not (contract_date_end and contract_date_start):
continue
# Compute recognized antique
antique_recognized += _compute_antique_from_dates(
contract_date_start, contract_date_end, days=True
)
payslip.antique_recognized = antique_recognized
@api.depends('line_ids')
......
......@@ -8,6 +8,8 @@
<data>
<xpath expr="//field[@name='other_id']" position="after">
<field name="last_contract_id"/>
<field name="antique_method"/>
<field name="antique_days"/>
</xpath>
</data>
</field>
......
......@@ -25,7 +25,7 @@
<group name="antique" string="Antique">
<label for="antique_months"/><div><field name="antique_months"/> Months</div>
<label for="antique_december"/><div><field name="antique_december"/> Months</div>
<label for="antique_recognized"/><div><field name="antique_recognized"/> Months</div>
<label for="antique_recognized"/><div><field name="antique_recognized"/> Days</div>
</group>
<group name="total_payment" string="Total Payment">
<field name="total_payment"/>
......
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