From 311ddc94f812daae8d7b7c02d6ba3668be7ef59d Mon Sep 17 00:00:00 2001 From: Facundo Barral <facundo.barral@eynes.com.ar> Date: Wed, 12 Jul 2023 13:46:54 -0300 Subject: [PATCH] [IMP] Migration from v12 to v15 --- __manifest__.py | 4 +- models/__init__.py | 2 +- models/bank_exports_history.py | 7 +-- models/hr_employee.py | 1 - models/impound_balance_lines.py | 12 ++-- models/res_bank.py | 1 + models/res_partner_bank.py | 2 +- views/bank_exports_history_views.xml | 6 +- views/hr_employee_cuil_visible_views.xml | 5 +- views/res_bank_constants_views.xml | 13 +++-- views/res_partner_bank_views.xml | 1 - wizard/alert_no_loans_views.xml | 3 +- wizard/alert_no_payslips_views.xml | 3 +- wizard/bank_parsers.py | 16 +++--- wizard/export_wizard.py | 64 ++++++++++----------- wizard/export_wizard_views.xml | 18 +++--- wizard/exportation_status_message_views.xml | 3 +- 17 files changed, 78 insertions(+), 83 deletions(-) diff --git a/__manifest__.py b/__manifest__.py index da8448e..e9977cb 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -20,10 +20,10 @@ # any module necessary for this one to work correctly 'depends': [ 'hr', - 'hr_payroll', + 'hr_payroll_community', 'hr_payroll_import', #used to make cuil visible 'hr_employee_loans', - 'embargos_rafaela', + # 'embargos_rafaela', ], # always loaded diff --git a/models/__init__.py b/models/__init__.py index c3fca18..6ba2a7b 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -6,4 +6,4 @@ from . import hr_employee from . import res_bank from . import res_partner_bank from . import hr_payslip -from . import impound_balance_lines +# from . import impound_balance_lines diff --git a/models/bank_exports_history.py b/models/bank_exports_history.py index 58f387d..feb91f9 100644 --- a/models/bank_exports_history.py +++ b/models/bank_exports_history.py @@ -10,7 +10,7 @@ class BankExportsHistory(models.Model): bank_id = fields.Many2one(comodel_name='res.bank', string='Banco') payslip_ids = fields.Many2many('hr.payslip', string='Nominas') loan_ids = fields.Many2many('hr.employee.loans', string='Préstamos') - impound_balance_line_ids = fields.Many2many('impound.balance.lines', string='Embargos') + # impound_balance_line_ids = fields.Many2many('impound.balance.lines', string='Embargos') file_name = fields.Char(string='Nombre', default='rafaela.txt') exported_file = fields.Binary(string='Archivo') comments = fields.Char(string="Comentarios") @@ -20,13 +20,12 @@ class BankExportsHistory(models.Model): ("payroll", "Nóminas"),], string="Tipo de Exportación",) - @api.multi def unlink(self): for export_history in self: for payslip in export_history.payslip_ids: payslip.update({'exported': False}) - for impound_line in export_history.impound_balance_line_ids: - impound_line.update({'exported': False}) + # for impound_line in export_history.impound_balance_line_ids: + # impound_line.update({'exported': False}) res = super(BankExportsHistory, self).unlink() return res diff --git a/models/hr_employee.py b/models/hr_employee.py index b488818..9775066 100644 --- a/models/hr_employee.py +++ b/models/hr_employee.py @@ -13,7 +13,6 @@ class HrEmployee(models.Model): string='Cuentas bancarias', readonly=False) - @api.model def write(self, vals): if vals.get('bank_ids') is not None: if vals['bank_ids'][-1][-1]: diff --git a/models/impound_balance_lines.py b/models/impound_balance_lines.py index 4bbc31f..15309f8 100644 --- a/models/impound_balance_lines.py +++ b/models/impound_balance_lines.py @@ -11,10 +11,10 @@ class ImpundBalanceLines(models.Model): impounds_id = fields.Many2one('impound.impound', invisible=True) impound_employee_name = fields.Char(related='impounds_id.employee.name') - impound_employee_warehouse_id = fields.Many2one( - related='impounds_id.employee.warehouse', - readonly=True, - store=True, - string='Employee Warehouse' - ) + # impound_employee_warehouse_id = fields.Many2one( + # related='impounds_id.employee.warehouse', + # readonly=True, + # store=True, + # string='Employee Warehouse' + # ) exported = fields.Boolean("Exportado", readonly=True) diff --git a/models/res_bank.py b/models/res_bank.py index 2610c8e..33d81f6 100644 --- a/models/res_bank.py +++ b/models/res_bank.py @@ -7,6 +7,7 @@ class ResBank(models.Model): _inherit = 'res.bank' + bank_code = fields.Char(string="Codigo Bancario (Exportación)") constants_ids = fields.One2many(comodel_name='bank.constants', inverse_name='bank_id', string='Constantes') select_bank = fields.Selection( [ diff --git a/models/res_partner_bank.py b/models/res_partner_bank.py index a3c3cbe..4f4c5fd 100644 --- a/models/res_partner_bank.py +++ b/models/res_partner_bank.py @@ -5,7 +5,7 @@ from odoo.exceptions import UserError class ResPartnerBank(models.Model): _inherit = 'res.partner.bank' - cbu = fields.Char(string='CBU', max=23) + cbu = fields.Char(string='CBU', size=22) branch_office = fields.Char(string='Sucursal') percentage = fields.Float(string="Porcentaje", default=0.0) bank = fields.Many2one('hr.employee') diff --git a/views/bank_exports_history_views.xml b/views/bank_exports_history_views.xml index 372f51c..a1f1d90 100644 --- a/views/bank_exports_history_views.xml +++ b/views/bank_exports_history_views.xml @@ -14,7 +14,7 @@ <field name="bank_id" readonly="1"/> <field name="payslip_ids" readonly="1" attrs="{'invisible': [('payslip_ids','=', [])]}"/> <field name="loan_ids" readonly="1" attrs="{'invisible': [('loan_ids','=', [])]}"/> - <field name="impound_balance_line_ids" readonly="1" attrs="{'invisible': [('impound_balance_line_ids','=', [])]}"/> + <!-- <field name="impound_balance_line_ids" readonly="1" attrs="{'invisible': [('impound_balance_line_ids','=', [])]}"/> --> <field name="file_name" invisible="1"/> <field name="comments" readonly="1"/> <field widget="binary" height="64" name="exported_file" filename="file_name"/> @@ -37,7 +37,7 @@ <field name="bank_id"/> <field name="payslip_ids"/> <field name="loan_ids"/> - <field name="impound_balance_line_ids"/> + <!-- <field name="impound_balance_line_ids"/> --> <field name="file_name" invisible="1"/> <field name="exported_file" filename="file_name"/> </tree> @@ -57,6 +57,6 @@ <!--Menu Bank--> - <menuitem id="bank_history_menu" name="Exportar archivo bancario" sequence="200" action="export_action" groups="rafaela_rrhh_custom.group_management_other_liquidations"/> + <menuitem id="bank_history_menu" name="Exportar archivo bancario" sequence="200" action="export_action"/> </odoo> diff --git a/views/hr_employee_cuil_visible_views.xml b/views/hr_employee_cuil_visible_views.xml index 1c8e7b2..baf4d83 100644 --- a/views/hr_employee_cuil_visible_views.xml +++ b/views/hr_employee_cuil_visible_views.xml @@ -7,11 +7,8 @@ <field name="inherit_id" ref="hr.view_employee_form"/> <field name="arch" type="xml"> - <xpath expr="//field[@name='identification_id']" position="after"> - <field name="cuil"/> - </xpath> <xpath expr="//field[@name='bank_account_id']" position="replace"> - <field name="bank_ids" attrs="{'invisible':[('payment_method', '!=', 'bank')]}"> + <field name="bank_ids"> <tree> <field name="bank_id" readonly="0"/> <field name="acc_number"/> diff --git a/views/res_bank_constants_views.xml b/views/res_bank_constants_views.xml index 728c4fd..263ea84 100644 --- a/views/res_bank_constants_views.xml +++ b/views/res_bank_constants_views.xml @@ -7,16 +7,19 @@ <field name="inherit_id" ref="base.view_res_bank_form"/> <field name="arch" type="xml"> - <xpath expr="//form/group[2]" position="after"> - <group string="Constantes"> + <xpath expr="//group[@name='communication_details']" position="after"> + <group string="Exportación"> + + <field name="select_bank"/> + <field name="bank_code"/> + + </group> + <group string="Constantes" colspan="6"> <field name="constants_ids"/> </group> </xpath> - <xpath expr="//field[@name='bic']" position="after"> - <field name="select_bank"/> - </xpath> </field> </record> diff --git a/views/res_partner_bank_views.xml b/views/res_partner_bank_views.xml index 0342991..e14ce50 100644 --- a/views/res_partner_bank_views.xml +++ b/views/res_partner_bank_views.xml @@ -8,7 +8,6 @@ <field name="arch" type="xml"> <xpath expr="//field[@name='acc_number']" position="after"> - <field name="cbu"/> <field name="branch_office"/> </xpath> <xpath expr="//field[@name='acc_holder_name']" position="after"> diff --git a/wizard/alert_no_loans_views.xml b/wizard/alert_no_loans_views.xml index 27f4a10..5f7cbd8 100644 --- a/wizard/alert_no_loans_views.xml +++ b/wizard/alert_no_loans_views.xml @@ -5,7 +5,6 @@ <record id="hr_exportation_status_action" model="ir.actions.act_window"> <field name="name">Exportacion de Créditos</field> <field name="res_model">hr.no.loans.message</field> - <field name="view_type">form</field> <field name="view_mode">form</field> <field name="target">new</field> </record> @@ -31,4 +30,4 @@ -</odoo> \ No newline at end of file +</odoo> diff --git a/wizard/alert_no_payslips_views.xml b/wizard/alert_no_payslips_views.xml index 1013e0d..4119555 100644 --- a/wizard/alert_no_payslips_views.xml +++ b/wizard/alert_no_payslips_views.xml @@ -5,7 +5,6 @@ <record id="hr_exportation_status_action" model="ir.actions.act_window"> <field name="name">Exportacion de nominas</field> <field name="res_model">hr.no.payslips.message</field> - <field name="view_type">form</field> <field name="view_mode">form</field> <field name="target">new</field> </record> @@ -31,4 +30,4 @@ -</odoo> \ No newline at end of file +</odoo> diff --git a/wizard/bank_parsers.py b/wizard/bank_parsers.py index 73c04d7..ac00fd7 100644 --- a/wizard/bank_parsers.py +++ b/wizard/bank_parsers.py @@ -242,7 +242,7 @@ class BBVAFormatter(TxtFormatter): constant_data[12] + " " * 2 + employee_data['employee_file'].zfill(15) + - employee_data['legacy_bank'] + + employee_data['bank_code'] + " " * 4 + constant_data[13] + employee_data['cbu'] + @@ -258,7 +258,7 @@ class BBVAFormatter(TxtFormatter): constant_data[15] + " " * 2 + employee_data['employee_file'].zfill(15) + - employee_data['legacy_bank'] + + employee_data['bank_code'] + " " * 4 + "{:<36.36s}".format(normalize(employee_data['name'])) @@ -269,7 +269,7 @@ class BBVAFormatter(TxtFormatter): constant_data[17] + " " * 2 + employee_data['employee_file'].zfill(15) + - employee_data['legacy_bank'] + employee_data['bank_code'] ) @@ -278,7 +278,7 @@ class BBVAFormatter(TxtFormatter): constant_data[19] + " " * 2 + employee_data['employee_file'].zfill(15) + - employee_data['legacy_bank'] + + employee_data['bank_code'] + " " * 4 + "{:<40}".format(employee_data['comments']) ) @@ -617,7 +617,7 @@ class OtrosBancosFormatter(TxtFormatter): constant_data[12] + " " * 2 + employee_data['employee_file'].zfill(15) + - employee_data['legacy_bank'] + + employee_data['bank_code'] + " " * 4 + constant_data[13] + employee_data['cbu'] + @@ -633,7 +633,7 @@ class OtrosBancosFormatter(TxtFormatter): constant_data[15] + " " * 2 + employee_data['employee_file'].zfill(15) + - employee_data['legacy_bank'] + + employee_data['bank_code'] + " " * 4 + "{:<36.36s}".format(normalize(employee_data['name'])) ) @@ -643,7 +643,7 @@ class OtrosBancosFormatter(TxtFormatter): constant_data[17] + " " * 2 + employee_data['employee_file'].zfill(15) + - employee_data['legacy_bank'] + employee_data['bank_code'] ) register4 = ( @@ -651,7 +651,7 @@ class OtrosBancosFormatter(TxtFormatter): constant_data[19] + " " * 2 + employee_data['employee_file'].zfill(15) + - employee_data['legacy_bank'] + + employee_data['bank_code'] + " " * 4 + "{:<40}".format(employee_data['comments']) ) diff --git a/wizard/export_wizard.py b/wizard/export_wizard.py index 20415d9..7f935fb 100644 --- a/wizard/export_wizard.py +++ b/wizard/export_wizard.py @@ -20,7 +20,7 @@ class Export_wizard(models.TransientModel): accreditation_date = fields.Date(string='Fecha de acreditacion') export_type = fields.Selection( [ - ("impound", "Embargos"), + # ("impound", "Embargos"), ("loan", "Préstamos"), ("payroll", "Nóminas"), ], @@ -29,9 +29,9 @@ class Export_wizard(models.TransientModel): ) paylisp_ids = fields.Many2many(sting='Nominas', comodel_name='hr.payslip') loan_ids = fields.Many2many(sting='Préstamos', comodel_name='hr.employee.loans') - impound_balance_line_ids = fields.Many2many( - sting='LÃneas de Embargo', - comodel_name='impound.balance.lines') + # impound_balance_line_ids = fields.Many2many( + # sting='LÃneas de Embargo', + # comodel_name='impound.balance.lines') acreditation_type = fields.Selection( [ ("transfer", "Transferencia"), @@ -60,17 +60,17 @@ class Export_wizard(models.TransientModel): readonly=True, store=True, string='Company Currency') - total_impounds_amount = fields.Monetary( - readonly=True, - store=False, - compute='_compute_impounds_amount', - currency_field='company_currency_id') - - @api.depends('impound_balance_line_ids.impound_novelties_quantity') - def _compute_impounds_amount(self): - for line in self: - self.total_impounds_amount = \ - sum(line.impound_balance_line_ids.mapped('impound_novelties_quantity')) + # total_impounds_amount = fields.Monetary( + # readonly=True, + # store=False, + # compute='_compute_impounds_amount', + # currency_field='company_currency_id') + + # @api.depends('impound_balance_line_ids.impound_novelties_quantity') + # def _compute_impounds_amount(self): + # # for line in self: + # # self.total_impounds_amount = \ + # # sum(line.impound_balance_line_ids.mapped('impound_novelties_quantity')) def _create_impound_domain(self, from_date, until_date, acreditation_type, impound_type, select_bank): valid_dates = set() @@ -114,13 +114,13 @@ class Export_wizard(models.TransientModel): ('state', '=', 'done'), ('exported', '=', False), ('total_payment', '>', 0.00), - ('employee_id.payment_method', '=', 'bank'), + # ('employee_id.payment_method', '=', 'bank'), ] loan_domain = [ ('loan_date', '>=', self.from_date), ('loan_date', '<=', self.until_date), - ('employee_id.payment_method', '=', 'bank'), + # ('employee_id.payment_method', '=', 'bank'), ] if self.bank_id.select_bank == 'OTROSBANCOS': @@ -179,7 +179,7 @@ class Export_wizard(models.TransientModel): acc = bank.acc_number.strip() if bank.acc_number else bank.acc_number cbu = bank.cbu.strip() if bank.cbu else bank.cbu office = bank.branch_office - legacy_bank = bank.bank_id.legacy_bank_code if bank.bank_id.select_bank != 'OTROSBANCOS' else '999' + bank_code = bank.bank_id.bank_code if bank.bank_id.select_bank != 'OTROSBANCOS' else '999' loan_records = [] for loan in loan_ids: @@ -191,14 +191,14 @@ class Export_wizard(models.TransientModel): 'total_payment': loan.total_import, 'bank_account_id': acc, 'cbu': loan.employee_id.cbu, - 'legacy_bank': legacy_bank, + 'bank_code': bank_code, 'cuil': loan.employee_id.cuil, 'accreditation_date': self.accreditation_date.strftime('%Y%m%d'), 'accreditation_type': '0004', 'branch_office': office, 'struct_type': '0004', 'comments': 'PRESTAMO', - 'warehouse': loan.employee_id.warehouse.name, + 'warehouse': loan.employee_id.work_location_id.name or "bank_report", } loan_records.append(record) @@ -283,26 +283,26 @@ class Export_wizard(models.TransientModel): 'acc': bank.acc_number.strip() if bank.acc_number else bank.acc_number, 'cbu': bank.cbu.strip() if bank.cbu else bank.cbu, 'office': bank.branch_office, - 'legacy_bank': bank.bank_id.legacy_bank_code if bank.bank_id.select_bank != 'OTROSBANCOS' else '999' + 'bank_code': '999' } bank_list.append(dic_bank) - + bank_perc = float(bank_list[0]['porcent']) or 100 record = { 'id': payslip.id, - 'total_payment': (float(payslip.total_payment) * float(bank_list[0]['porcent'])) / 100, + 'total_payment': (float(payslip.total_payment) * bank_perc) / 100, 'name': payslip.employee_id.name, 'identification_id': payslip.employee_id.identification_id, 'employee_file': str(payslip.employee_id.other_id).strip(), 'bank_account_id': bank_list[0]['acc'], 'cbu': bank_list[0]['cbu'], - 'legacy_bank': bank_list[0]['legacy_bank'], + 'bank_code': bank_list[0]['bank_code'], 'cuil': payslip.employee_id.cuil, 'accreditation_date': self.accreditation_date.strftime('%Y%m%d'), - 'accreditation_type': payslip.struct_type.name, + 'accreditation_type': payslip.struct_id.struct_type_id.name, 'branch_office': bank_list[0]['office'], - 'struct_type':payslip.struct_type.name, + 'struct_type':payslip.struct_id.struct_type_id.name, 'comments': 'HABERES RAFAELA', - 'warehouse': payslip.employee_id.warehouse.name, + 'warehouse': payslip.employee_id.work_location_id.name or "bank_report", } payslip_records.append(record) @@ -312,7 +312,7 @@ class Export_wizard(models.TransientModel): for cte in self.bank_id.constants_ids.filtered(lambda r: r.export_type != 'impound'): bank_constants[cte.constant_order - 1] = cte.value elif self.bank_id.select_bank == 'OTROSBANCOS': - other_bank = self.env['res.bank'].search([('legacy_bank_code', '=', '999')]) + other_bank = self.env['res.bank'].search([('bank_code', '=', '999')]) if other_bank: for cte in other_bank.constants_ids: bank_constants[cte.constant_order - 1] = cte.value @@ -395,7 +395,7 @@ class Export_wizard(models.TransientModel): 'porcent': float(100), 'acc': impound_line.impounds_id.account_number.strip().replace('/', '').zfill(12) if impound_line.impounds_id.account_number else False, 'office': '{:>04}'.format(impound_line.impounds_id.branch_office_number), - 'legacy_bank': bank.bank_id.legacy_bank_code if bank.bank_id.select_bank != 'OTROSBANCOS' else '999', + 'bank_code': bank.bank_id.bank_code if bank.bank_id.select_bank != 'OTROSBANCOS' else '999', } bank_list.append(dic_bank) employee = impound_line.impounds_id.employee @@ -412,7 +412,7 @@ class Export_wizard(models.TransientModel): 'identification_id': employee.identification_id, 'employee_file': str(employee.other_id).strip(), 'bank_account_id': bank_list[0]['acc'], - 'legacy_bank': bank_list[0]['legacy_bank'], + 'bank_code': bank_list[0]['bank_code'], 'cuil': employee.cuil, 'accreditation_date': self.accreditation_date.strftime('%Y%m%d'), 'acreditation_type': self.acreditation_type, @@ -420,7 +420,7 @@ class Export_wizard(models.TransientModel): 'branch_office': bank_list[0]['office'], 'struct_type': 'impound', 'comments': 'EMBARGOS', - 'warehouse': employee.warehouse.name, + 'warehouse': employee.work_location_id.name or "bank_report", 'cbu': impound_line.impounds_id.cbu, 'file_number': impound_line.impounds_id.file_number, 'curt': impound_line.impounds_id.curt, @@ -443,7 +443,7 @@ class Export_wizard(models.TransientModel): for cte in self.bank_id.constants_ids: bank_constants[cte.constant_order - 1] = cte.value elif self.bank_id.select_bank == 'OTROSBANCOS': - other_bank = self.env['res.bank'].search([('legacy_bank_code', '=', '999')]) + other_bank = self.env['res.bank'].search([('bank_code', '=', '999')]) if other_bank: for cte in other_bank.constants_ids: bank_constants[cte.constant_order - 1] = cte.value diff --git a/wizard/export_wizard_views.xml b/wizard/export_wizard_views.xml index e92b5de..bd6dc2f 100644 --- a/wizard/export_wizard_views.xml +++ b/wizard/export_wizard_views.xml @@ -43,7 +43,7 @@ /> </group> - <group> + <group colspan="6"> <field name="paylisp_ids" string='Nóminas' attrs="{ 'invisible': ['|','|','|',('from_date','=', False),('until_date', '=', False),('accreditation_date', '=', False),('export_type', '!=', 'payroll')]}" @@ -52,7 +52,7 @@ attrs="{ 'invisible': ['|','|','|',('from_date','=', False),('until_date', '=', False),('accreditation_date', '=', False),('export_type', '!=', 'loan')]}" /> - <field name="impound_balance_line_ids" string='Embargos' + <!-- <field name="impound_balance_line_ids" string='Embargos' attrs="{ 'invisible': ['|','|','|',('from_date','=', False),('until_date', '=', False),('accreditation_date', '=', False),('export_type', '!=', 'impound')], }" @@ -64,12 +64,12 @@ <field name="impound_novelties_year"/> <field name="impound_novelties_quantity"/> </tree> - </field> + </field> --> - <field name="total_impounds_amount" string='Total' + <!-- <field name="total_impounds_amount" string='Total' attrs="{ 'invisible': ['|','|','|',('from_date','=', False),('until_date', '=', False),('accreditation_date', '=', False),('export_type', '!=', 'impound')]}" - /> + /> --> </group> </group> @@ -82,7 +82,7 @@ </field> </record> - <record id="view_impound_balance_lines_tree" model="ir.ui.view"> + <!-- <record id="view_impound_balance_lines_tree" model="ir.ui.view"> <field name="name">impound.balance.lines.tree</field> <field name="model">impound.balance.lines</field> <field name="arch" type="xml"> @@ -94,9 +94,9 @@ <field name="impound_novelties_quantity"/> </tree> </field> - </record> + </record> --> - <record id="view_impound_balance_lines_search" model="ir.ui.view"> + <!-- <record id="view_impound_balance_lines_search" model="ir.ui.view"> <field name="model">impound.balance.lines</field> <field name="arch" type="xml"> <search> @@ -110,7 +110,7 @@ </group> </search> </field> - </record> + </record> --> <menuitem id="export_file_wizard" name="Generar archivo" sequence="1" parent="bank_history_menu" action="export_wizard" /> diff --git a/wizard/exportation_status_message_views.xml b/wizard/exportation_status_message_views.xml index b84989a..d16bf24 100644 --- a/wizard/exportation_status_message_views.xml +++ b/wizard/exportation_status_message_views.xml @@ -5,7 +5,6 @@ <record id="hr_exportation_status_action" model="ir.actions.act_window"> <field name="name">Exportacion de nominas</field> <field name="res_model">hr.status.exportation.message</field> - <field name="view_type">form</field> <field name="view_mode">form</field> <field name="target">new</field> </record> @@ -31,4 +30,4 @@ -</odoo> \ No newline at end of file +</odoo> -- GitLab