From 7a578394af0e779e88fbd5a87851874443c4e785 Mon Sep 17 00:00:00 2001 From: Luis Felipe Mileo Date: Wed, 22 Feb 2017 17:18:36 -0300 Subject: [PATCH] [REF] Convert to better write --- l10n_br_hr_payroll/models/hr_contract.py | 4 +- l10n_br_hr_payroll/models/hr_payslip.py | 60 ++++++++++++++---------- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/l10n_br_hr_payroll/models/hr_contract.py b/l10n_br_hr_payroll/models/hr_contract.py index 674cf2f2d..14b545f05 100644 --- a/l10n_br_hr_payroll/models/hr_contract.py +++ b/l10n_br_hr_payroll/models/hr_contract.py @@ -133,5 +133,7 @@ def _salario_mes(self, data_inicio, data_fim): company_id = fields.Many2one( comodel_name='res.company', string='Empresa', - required=True, + # required=True, + # default=lambda self: self.env['res.company']._company_default_get( + # 'hr.contract') ) diff --git a/l10n_br_hr_payroll/models/hr_payslip.py b/l10n_br_hr_payroll/models/hr_payslip.py index 70430c187..273353a5e 100644 --- a/l10n_br_hr_payroll/models/hr_payslip.py +++ b/l10n_br_hr_payroll/models/hr_payslip.py @@ -91,32 +91,40 @@ def _valor_total_folha(self): inss = line.total elif codigo['IRPF']: irpf = line.total - holerite.total_folha = total - holerite.total_proventos = total_proventos - holerite.total_descontos = total_descontos - holerite.base_fgts = base_fgts - holerite.base_inss = base_inss - holerite.base_irpf = base_irpf - holerite.fgts = fgts - holerite.inss = inss - holerite.irpf = irpf - # Formato - holerite.data_admissao_fmt =\ - data.formata_data(holerite.contract_id.date_start) - holerite.salario_base_fmt =\ - valor.formata_valor(holerite.contract_id.wage) - holerite.total_folha_fmt =\ - valor.formata_valor(holerite.total_folha) - holerite.total_proventos_fmt =\ - valor.formata_valor(holerite.total_proventos) - holerite.total_descontos_fmt =\ - valor.formata_valor(holerite.total_descontos) - holerite.base_fgts_fmt = valor.formata_valor(holerite.base_fgts) - holerite.base_inss_fmt = valor.formata_valor(holerite.base_inss) - holerite.base_irpf_fmt = valor.formata_valor(holerite.base_irpf) - holerite.fgts_fmt = valor.formata_valor(holerite.fgts) - holerite.inss_fmt = valor.formata_valor(holerite.inss) - holerite.irpf_fmt = valor.formata_valor(holerite.irpf) + holerite.write({ + 'total_folha': total, + 'total_proventos': total_proventos, + 'total_descontos': total_descontos, + 'base_fgts': base_fgts, + 'base_inss': base_inss, + 'base_irpf': base_irpf, + 'fgts': fgts, + 'inss': inss, + 'irpf': irpf, + # Formato + 'data_admissao_fmt': data.formata_data( + holerite.contract_id.date_start), + 'salario_base_fmt': valor.formata_valor( + holerite.contract_id.wage), + 'total_folha_fmt': valor.formata_valor( + holerite.total_folha), + 'total_proventos_fmt': valor.formata_valor( + holerite.total_proventos), + 'total_descontos_fmt': valor.formata_valor( + holerite.total_descontos), + 'base_fgts_fmt': valor.formata_valor( + holerite.base_fgts), + 'base_inss_fmt': valor.formata_valor( + holerite.base_inss), + 'base_irpf_fmt': valor.formata_valor( + holerite.base_irpf), + 'fgts_fmt': valor.formata_valor( + holerite.fgts), + 'inss_fmt': valor.formata_valor( + holerite.inss), + 'irpf_fmt': valor.formata_valor( + holerite.irpf), + }) employee_id_readonly = fields.Many2one( string=u'Funcionário',