From 5c0c9493a4b98842474cd6c559f1441956e31527 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Wed, 11 May 2022 15:03:58 +0200 Subject: [PATCH 01/49] [REF] account_edi: allowing moves of entry type to be sent when necessary --- .../models/account_edi_document.py | 6 ++--- addons/account_edi/models/account_move.py | 25 ++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/addons/account_edi/models/account_edi_document.py b/addons/account_edi/models/account_edi_document.py index fa863a8ada40e3..daa00f8dd359ca 100644 --- a/addons/account_edi/models/account_edi_document.py +++ b/addons/account_edi/models/account_edi_document.py @@ -52,7 +52,7 @@ def _compute_edi_content(self): config_errors = doc.edi_format_id._check_move_configuration(move) if config_errors: res = base64.b64encode('\n'.join(config_errors).encode('UTF-8')) - elif move.is_invoice(include_receipts=True) and doc.edi_format_id._is_required_for_invoice(move): + elif move._is_edi_invoice() and doc.edi_format_id._is_required_for_invoice(move): res = base64.b64encode(doc.edi_format_id._get_invoice_edi_content(doc.move_id)) elif move.payment_id and doc.edi_format_id._is_required_for_payment(move): res = base64.b64encode(doc.edi_format_id._get_payment_edi_content(doc.move_id)) @@ -82,7 +82,7 @@ def _prepare_jobs(self): for edi_doc in documents: move = edi_doc.move_id edi_format = edi_doc.edi_format_id - if move.is_invoice(include_receipts=True): + if move._is_edi_invoice(): doc_type = 'invoice' elif move.payment_id or move.statement_line_id: doc_type = 'payment' @@ -159,7 +159,7 @@ def _postprocess_cancel_edi_results(documents, edi_result): 'blocking_level': False, }) - if move.is_invoice(include_receipts=True) and move.state == 'posted': + if move._is_edi_invoice() and move.state == 'posted': # The user requested a cancellation of the EDI and it has been approved. Then, the invoice # can be safely cancelled. invoice_ids_to_cancel.add(move.id) diff --git a/addons/account_edi/models/account_move.py b/addons/account_edi/models/account_move.py index 181ed78e059141..421600cc92e728 100644 --- a/addons/account_edi/models/account_move.py +++ b/addons/account_edi/models/account_move.py @@ -100,7 +100,7 @@ def _compute_show_reset_to_draft_button(self): for doc in move.edi_document_ids: if doc.edi_format_id._needs_web_services() \ and doc.state in ('sent', 'to_cancel') \ - and move.is_invoice(include_receipts=True) \ + and move._is_edi_invoice() \ and doc.edi_format_id._is_required_for_invoice(move): move.show_reset_to_draft_button = False break @@ -116,7 +116,7 @@ def _compute_edi_show_cancel_button(self): move.edi_show_cancel_button = any([doc.edi_format_id._needs_web_services() and doc.state == 'sent' - and move.is_invoice(include_receipts=True) + and move._is_edi_invoice() and doc.edi_format_id._is_required_for_invoice(move) for doc in move.edi_document_ids]) @@ -127,10 +127,23 @@ def _compute_edi_show_abandon_cancel_button(self): for move in self: move.edi_show_abandon_cancel_button = any(doc.edi_format_id._needs_web_services() and doc.state == 'to_cancel' - and move.is_invoice(include_receipts=True) + and move._is_edi_invoice() and doc.edi_format_id._is_required_for_invoice(move) for doc in move.edi_document_ids) + def _is_edi_invoice(self): + """To be overridden for special cases where entry types need to be sent. """ + self.ensure_one() + return self._get_edi_document_type() == 'invoice' + + def _get_edi_document_type(self, edi_format=None): + """Defines the document types that are exchanged through the EDI. """ + self.ensure_one() + if self.is_invoice(include_receipts=False): + return 'invoice' + elif self.payment_id or self.statement_line_id: + return 'payment' + #################################################### # Export Electronic Document #################################################### @@ -503,7 +516,7 @@ def _post(self, soft=True): edi_document_vals_list = [] for move in posted: for edi_format in move.journal_id.edi_format_ids: - is_edi_needed = move.is_invoice(include_receipts=False) and edi_format._is_required_for_invoice(move) + is_edi_needed = move._is_edi_invoice() and edi_format._is_required_for_invoice(move) if is_edi_needed: errors = edi_format._check_move_configuration(move) @@ -565,7 +578,7 @@ def button_cancel_posted_moves(self): if doc.edi_format_id._needs_web_services() \ and doc.attachment_id \ and doc.state == 'sent' \ - and move.is_invoice(include_receipts=True) \ + and move._is_edi_invoice() \ and doc.edi_format_id._is_required_for_invoice(move): to_cancel_documents |= doc is_move_marked = True @@ -582,7 +595,7 @@ def button_abandon_cancel_posted_posted_moves(self): is_move_marked = False for doc in move.edi_document_ids: if doc.state == 'to_cancel' \ - and move.is_invoice(include_receipts=True) \ + and move._is_edi_invoice() \ and doc.edi_format_id._is_required_for_invoice(move): documents |= doc is_move_marked = True From 2011b1982645301ef945cafe722f2bd1da6d8e6f Mon Sep 17 00:00:00 2001 From: Stanislas Gueniffey Date: Thu, 14 Jul 2022 11:17:08 +0200 Subject: [PATCH 02/49] [IMP] l10n_ec: update and upgrade Data improvements: - Added missing tax groups - Added VAT 8%, used for tourism operations on special hollidays - Fixes base percentage on Withhold VAT taxes - Corrected tax name from Iva to IVA - Improves SRI paymment options, with sequence widget and inactavtes deprecated payment options. - Fixes short code of document types - Corrects document type name for insurance - Adds withhold document type, to be implemented in separated module Other improvements: - Automatic setup of several journals when creating new companies - Adds restrictions to ensure proper setup of ecuadorian journals - Improves ecuadorian journal form More improvements: - Removes unused fiscal positions - Removes unnecessary journals - Desactivates unused payment methods - Adds migration scripts - Add SRI Root menu - More fixes and improvements Co-authored-by: Andres Calle --- addons/l10n_ec/__manifest__.py | 15 +- .../account_chart_template_setup_accounts.xml | 2 +- .../data/account_fiscal_position_template.xml | 48 +- .../data/account_group_template_data.xml | 6 +- .../l10n_ec/data/account_tax_group_data.xml | 33 +- .../data/account_tax_template_vat_data.xml | 133 ++++-- ...ount_tax_template_withhold_profit_data.xml | 438 ++++++++++-------- ...account_tax_template_withhold_vat_data.xml | 124 ++--- addons/l10n_ec/data/l10n_ec.sri.payment.csv | 18 +- .../l10n_ec/data/l10n_latam.document.type.csv | 75 +-- addons/l10n_ec/demo/demo_company.xml | 4 +- .../l10n_ec/migrations/3.4/post-migration.py | 87 ++++ addons/l10n_ec/models/__init__.py | 1 + .../l10n_ec/models/account_chart_template.py | 19 + addons/l10n_ec/models/account_journal.py | 16 +- addons/l10n_ec/models/account_tax_group.py | 25 +- addons/l10n_ec/models/l10n_ec_sri_payment.py | 5 +- .../models/l10n_latam_document_type.py | 2 +- addons/l10n_ec/models/res_partner.py | 4 +- addons/l10n_ec/views/account_journal_view.xml | 24 +- addons/l10n_ec/views/l10n_ec_sri_payment.xml | 32 +- addons/l10n_ec/views/root_sri_menu.xml | 8 + 22 files changed, 686 insertions(+), 433 deletions(-) create mode 100644 addons/l10n_ec/migrations/3.4/post-migration.py create mode 100644 addons/l10n_ec/models/account_chart_template.py create mode 100644 addons/l10n_ec/views/root_sri_menu.xml diff --git a/addons/l10n_ec/__manifest__.py b/addons/l10n_ec/__manifest__.py index aa454fa91da62e..039cb11ce0214e 100644 --- a/addons/l10n_ec/__manifest__.py +++ b/addons/l10n_ec/__manifest__.py @@ -2,7 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. { "name": "Ecuadorian Accounting", - "version": "3.3", + "version": "3.4", "description": """ Functional ---------- @@ -32,10 +32,10 @@ * Ecuador banks * Partners: Consumidor Final, SRI, IESS, and also basic VAT validation """, - "author": "OPA CONSULTING & TRESCLOUD", + "author": "TRESCLOUD & OPA CONSULTING", "category": "Accounting/Localizations/Account Charts", - "maintainer": "OPA CONSULTING", - "website": "https://opa-consulting.com", + "maintainer": "TRESCLOUD", + "website": "https://www.trescloud.com", "license": "LGPL-3", "depends": [ "base", @@ -46,6 +46,8 @@ "l10n_latam_base", ], "data": [ + # Security + "security/ir.model.access.csv", # Chart of Accounts "data/account_chart_template_data.xml", "data/account_group_template_data.xml", @@ -63,14 +65,15 @@ "data/l10n_latam_identification_type_data.xml", "data/res_partner_data.xml", # Other data - "data/account_chart_template_configure_data.xml", "data/l10n_latam.document.type.csv", + "data/account_chart_template_configure_data.xml", "data/l10n_ec.sri.payment.csv", + # Views + "views/root_sri_menu.xml", "views/account_tax_view.xml", "views/l10n_latam_document_type_view.xml", "views/l10n_ec_sri_payment.xml", "views/account_journal_view.xml", - "security/ir.model.access.csv", ], "demo": [ "demo/demo_company.xml", diff --git a/addons/l10n_ec/data/account_chart_template_setup_accounts.xml b/addons/l10n_ec/data/account_chart_template_setup_accounts.xml index 01642c130743d8..5fbd8504576158 100644 --- a/addons/l10n_ec/data/account_chart_template_setup_accounts.xml +++ b/addons/l10n_ec/data/account_chart_template_setup_accounts.xml @@ -3,7 +3,7 @@ - Plan Contable NIIF Ecuador conforme Superintendencia de Compañías + Ecuador - Plan Cuentas NIIF SupCias diff --git a/addons/l10n_ec/data/account_fiscal_position_template.xml b/addons/l10n_ec/data/account_fiscal_position_template.xml index 981600d6c9db16..e180a3a8c75d3c 100644 --- a/addons/l10n_ec/data/account_fiscal_position_template.xml +++ b/addons/l10n_ec/data/account_fiscal_position_template.xml @@ -1,55 +1,11 @@ - - - Sociedades - personas juridicas - - - - Contribuyentes especiales - - - - Sector publico y ep - - - - Persona natural obligada a llevar contabilidad - - - - Persona natural no obligada - arriendos - - - - Persona natural no obligada - profesionales - - - - Persona natural no obligada - liquidaciones de compras - - - - Persona natural no obligadas - emite factura o nota de venta - - - - Empresa extranjera - venta local - - - - Persona extranjera - venta local - - Empresa extranjera - exportacion + Empresa extranjera - Persona extranjera - exportacion - - - - Otras - sin cálculo automático de retención de iva + Persona extranjera diff --git a/addons/l10n_ec/data/account_group_template_data.xml b/addons/l10n_ec/data/account_group_template_data.xml index dc63ae475a4666..7796607688969d 100644 --- a/addons/l10n_ec/data/account_group_template_data.xml +++ b/addons/l10n_ec/data/account_group_template_data.xml @@ -118,7 +118,7 @@ 110501 - Credito tributario a favor de la empresa(iva) + Credito tributario a favor de la empresa(IVA) @@ -299,7 +299,7 @@ 21140101 - Iva cobrado + IVA cobrado @@ -313,7 +313,7 @@ 21140103 - Retenciones de iva + Retenciones de IVA diff --git a/addons/l10n_ec/data/account_tax_group_data.xml b/addons/l10n_ec/data/account_tax_group_data.xml index 72b32429fe9819..2a150b1d2d8beb 100644 --- a/addons/l10n_ec/data/account_tax_group_data.xml +++ b/addons/l10n_ec/data/account_tax_group_data.xml @@ -2,6 +2,13 @@ + + VAT 8% + vat08 + 5 + + + VAT 12% vat12 @@ -51,16 +58,30 @@ - - VAT Withhold - withhold_vat + + VAT Withhold on Sales + withhold_vat_sale + 80 + + + + + VAT Withhold on Purchases + withhold_vat_purchase 80 - - Profit Withhold - withhold_income_tax + + Profit Withhold on Sales + withhold_income_sale + 90 + + + + + Profit Withhold on Purchases + withhold_income_purchase 90 diff --git a/addons/l10n_ec/data/account_tax_template_vat_data.xml b/addons/l10n_ec/data/account_tax_template_vat_data.xml index b2312f9035bb90..ce033cc084b813 100644 --- a/addons/l10n_ec/data/account_tax_template_vat_data.xml +++ b/addons/l10n_ec/data/account_tax_template_vat_data.xml @@ -6,7 +6,7 @@ --> - Iva 12% + IVA 12% sale percent 9 @@ -43,7 +43,7 @@ - Iva 12% (activos) + IVA 12% (Activos) sale percent 10 @@ -69,18 +69,18 @@ (0,0, { 'factor_percent': 100, 'repartition_type': 'base', - 'minus_report_line_ids': [ref('tax_report_line_104_411')], + 'minus_report_line_ids': [ref('tax_report_line_104_412')], }), (0,0, { 'factor_percent': 100, 'repartition_type': 'tax', 'account_id': ref('l10n_ec.ec_sale_vat'), - 'minus_report_line_ids': [ref('tax_report_line_104_421')], + 'minus_report_line_ids': [ref('tax_report_line_104_422')], })]"/> - Iva 0% + IVA 0% sale percent 19 @@ -114,7 +114,7 @@ - Iva 0% (activos) + IVA 0% (Activos) sale percent 20 @@ -127,7 +127,7 @@ (0,0, { 'factor_percent': 100, 'repartition_type': 'base', - 'plus_report_line_ids': [ref('tax_report_line_104_414')], + 'plus_report_line_ids': [ref('tax_report_line_104_416')], }), (0,0, { 'factor_percent': 100, @@ -138,7 +138,7 @@ (0,0, { 'factor_percent': 100, 'repartition_type': 'base', - 'minus_report_line_ids': [ref('tax_report_line_104_414')], + 'minus_report_line_ids': [ref('tax_report_line_104_416')], }), (0,0, { 'factor_percent': 100, @@ -148,7 +148,7 @@ - Iva 0% (sin crédito tributario) + IVA 0% (Sin Crédito Tributario) sale percent 20 @@ -182,7 +182,7 @@ - Iva 0% (activos sin crédito tributario) + IVA 0% (Activos Sin Crédito Tributario) sale percent 20 @@ -216,7 +216,7 @@ - Iva 0% (exportación bienes) + IVA 0% (Exportación Bienes) sale percent 21 @@ -250,7 +250,7 @@ - Iva 0% (exportación servicios) + IVA 0% (Exportación Servicios) sale percent 21 @@ -284,7 +284,7 @@ - Iva 0% (no objeto/exentas) + IVA 0% (No Objeto/Exentas) sale percent 40 @@ -319,7 +319,7 @@ - Iva 12% (reembolso) + IVA 12% (Reembolso) sale percent 10 @@ -333,30 +333,67 @@ (0,0, { 'factor_percent': 100, 'repartition_type': 'base', - 'plus_report_line_ids': [ref('tax_report_line_104_412')], + 'plus_report_line_ids': [ref('tax_report_line_104_444')], }), (0,0, { 'factor_percent': 100, 'repartition_type': 'tax', 'account_id': ref('l10n_ec.ec_other_downpayments'), - 'plus_report_line_ids': [ref('tax_report_line_104_422')], + 'plus_report_line_ids': [ref('tax_report_line_104_454')], })]"/> + + + + IVA 8% + sale + percent + 50 + 8.0 + IVA 8% + 411 + 421 + + + + - + - Iva 12% + IVA 12% purchase percent 9 @@ -393,7 +430,7 @@ - Iva 12% (activos) + IVA 12% (Activos) purchase percent 10 @@ -430,7 +467,7 @@ - Iva 12% (sin crédito tributario) + IVA 12% (Sin Crédito Tributario) purchase percent 10 @@ -465,7 +502,7 @@ - Iva 12% (importación servicios) + IVA 12% (Importación Servicios) purchase percent 10 @@ -502,7 +539,7 @@ - Iva 12% (importación bienes) + IVA 12% (Importación Bienes) purchase percent 10 @@ -539,7 +576,7 @@ - Iva 12% (importación activos) + IVA 12% (Importación Activos) purchase percent 10 @@ -576,7 +613,7 @@ - Iva 0% + IVA 0% purchase percent 20 @@ -611,7 +648,7 @@ - Iva 0% (importación bienes) + IVA 0% (Importación Bienes) purchase percent 20 @@ -645,7 +682,7 @@ - Iva 0% (rise) + IVA 0% (Rise) purchase percent 20 @@ -679,7 +716,7 @@ - Iva 0% (no objeto de iva) + IVA 0% (No Objeto de IVA) purchase percent 30 @@ -713,7 +750,7 @@ - Iva 0% (excento de iva) + IVA 0% (Excento de IVA) purchase percent 40 @@ -747,7 +784,7 @@ - Iva 12% (reembolso intermediario) + IVA 12% (Reembolso Intermediario) purchase percent 10 @@ -782,5 +819,41 @@ 'minus_report_line_ids': [ref('tax_report_line_104_555')], })]"/> + + IVA 8% + purchase + percent + 50 + 8.0 + IVA 8% + 510 + 520 + + + + + diff --git a/addons/l10n_ec/data/account_tax_template_withhold_profit_data.xml b/addons/l10n_ec/data/account_tax_template_withhold_profit_data.xml index 8c282fb8f48ced..f1632424956bd0 100644 --- a/addons/l10n_ec/data/account_tax_template_withhold_profit_data.xml +++ b/addons/l10n_ec/data/account_tax_template_withhold_profit_data.xml @@ -5,8 +5,8 @@ PURCHASE WITHHOLDS OVER ANTICIPADED PROFIT *IMPUESTO A LA RENTA --> - 303 10% honorarios profesionales y demas pagos por servicios relacionados con el titulo profesional - purchase + 303 10% Honorarios Profesionales y Demás Pagos por Servicios Relacionados con el Titulo Profesional + none percent 70 -10.0 @@ -15,7 +15,7 @@ 303 303 - + - 304 8% servicios predomina el intelecto no relacionados con el titulo profesional - purchase + 304 8% Servicios Predomina el Intelecto No Relacionados con el Titulo Profesional + none percent 70 -8.0 @@ -52,7 +52,7 @@ 304 304 - + - 304a 8% comisiones y demas pagos por servicios predomina intelecto no relacionados con el titulo profesional - purchase + 304A 8% Comisiones y Demas Pagos por Servicios Predomina Intelecto No Relacionados con el Titulo Profesional + none percent 70 -8.0 @@ -89,7 +89,7 @@ 304 304A - + - 304b 8% pagos a notarios y registradores de la propiedad y mercantil por sus actividades ejercidas como tales - purchase + 304B 8% Pagos a Notarios y Registradores de la Propiedad y Mercantil por sus Actividades Ejercidas Como Tales + none percent 70 -8.0 @@ -126,7 +126,7 @@ 304 304B - + - 304c 8% pagos a deportistas, entrenadores, arbitros, miembros del cuerpo tecnico por sus actividades ejercidas como tales - purchase + 304C 8% Pagos a Deportistas, Entrenadores, Arbitros, Miembros del Cuerpo Tecnico por sus Actividades Ejercidas Como Tales + none percent 70 -8.0 @@ -163,7 +163,7 @@ 304 304C - + - 304d 8% pagos a artistas por sus actividades ejercidas como tales - purchase + 304D 8% Pagos a Artistas por sus Actividades Ejercidas Como Tales + none percent 70 -8.0 @@ -200,7 +200,7 @@ 304 304D - + - 304e 8% honorarios y demas pagos por servicios de docencia - purchase + 304E 8% Honorarios y Demas Pagos por Servicios de Docencia + none percent 70 -8.0 @@ -237,7 +237,7 @@ 304 304E - + - 307 2% servicios predomina mano de obra - purchase + 307 2% Servicios Predomina Mano de Obra + none percent 70 -2.0 @@ -274,7 +274,7 @@ 307 307 - + - 308 10% utilizacion o aprovechamiento de la imagen o renombre - purchase + 308 10% Utilizacion o Aprovechamiento de la Imagen o Renombre + none percent 70 -10.0 @@ -311,7 +311,7 @@ 308 308 - + - 309 1.75% servicios prestados por medios de comunicación y agencias de publicidad - purchase + 309 1.75% Servicios Prestados por Medios de Comunicación y Agencias de Publicidad + none percent 70 -1.75 @@ -348,7 +348,7 @@ 309 309 - + - 310 1% servicio de transporte privado de pasajeros o transporte publico o privado de carga - purchase + 310 1% Servicio de Transporte Privado de Pasajeros o Transporte Publico o Privado de Carga + none percent 70 -1.0 @@ -385,7 +385,7 @@ 310 310 - + - 311 2% por pagos a traves de liquidacion de compra (nivel cultural o rusticidad) - purchase + 311 2% Por Pagos a Traves de Liquidacion de Compra (nivel cultural o rusticidad) + none percent 70 -2.0 @@ -422,7 +422,7 @@ 311 311 - + - 312 1.75% transferencia de bienes muebles de naturaleza corporal - purchase + 312 1.75% Transferencia de Bienes Muebles de Naturaleza Corporal + none percent 70 -1.75 @@ -459,7 +459,7 @@ 312 312 - + - 312a 1% compra de bienes de origen agricola, avicola, pecuario, apicola, cunicula, bioacuatico, y forestal - purchase + 312A 1% Compra de Bienes de Origen Agricola, Avicola, Pecuario, Apicola, Cunicula, Bioacuatico, y Forestal + none percent 70 -1.0 @@ -496,7 +496,7 @@ 312 312A - + - 314a 8% regalias por concepto de franquicias de acuerdo a ley de propiedad intelectual - pago a personas naturales - purchase + 314A 8% Regalias por Concepto de Franquicias de Acuerdo a Ley de Propiedad Intelectual - Pago a Personas Naturales + none percent 70 -8.0 @@ -533,7 +533,7 @@ 314 314A - + - 314b 8% casales, derechos de autor, marcas, patentes y similares de acuerdo a ley de propiedad intelectual – pago a personas naturales - purchase + 314B 8% Casales, Derechos de Autor, Marcas, Patentes y Similares de Acuerdo a Ley de Propiedad Intelectual – Pago a Personas Naturales + none percent 70 -8.0 @@ -570,7 +570,7 @@ 314 314B - + - 314c 8% regalias por concepto de franquicias de acuerdo a ley de propiedad intelectual - pago a sociedades - purchase + 314C 8% Regalias por Concepto de Franquicias de Acuerdo a Ley de Propiedad Intelectual - Pago a Sociedades + none percent 70 -8.0 @@ -607,7 +607,7 @@ 314 314C - + - 314d 8% casales, derechos de autor, marcas, patentes y similares de acuerdo a ley de propiedad intelectual – pago a sociedades - purchase + 314D 8% Casales, Derechos de Autor, Marcas, Patentes y Similares de Acuerdo a Ley de Propiedad Intelectual – Pago a Sociedades + none percent 70 -8.0 @@ -644,7 +644,7 @@ 314 314D - + - 319 1.75% cuotas de arrendamiento mercantil (prestado por sociedades), inclusive la de opción de compra - purchase + 319 1.75% Cuotas de Arrendamiento Mercantil (Prestado por Sociedades), Inclusive la de Opción de Compra + none percent 70 -1.75 @@ -681,7 +681,7 @@ 319 319 - + - 320 8% por arrendamiento bienes inmuebles - purchase + 320 8% Por Arrendamiento Bienes Inmuebles + none percent 70 -8.0 @@ -718,7 +718,7 @@ 320 320 - + - 322 1.75% seguros y reaseguros (primas y cesiones) 1.75% - purchase + 322 1.75% Seguros y Reaseguros (Primas y Cesiones) 1.75% + none percent 70 -1.75 @@ -755,7 +755,7 @@ 322 322 - + - 332 0% otras compras de bienes y servicios no sujetas a retencion - purchase + 332 0% Otras Compras de Bienes y Servicios No Sujetas a Retencion + none percent 70 0.0 @@ -791,7 +791,7 @@ 332 332 - + - 332a 0% enajenacion de derechos representativos de capital y otros derechos exentos (mayo 2016) - purchase + 332A 0% Enajenacion de Derechos Representativos de Capital y Otros Derechos Exentos (mayo 2016) + none percent 70 0.0 @@ -825,7 +825,7 @@ 332 332A - + - 332b 0% compra de bienes inmuebles - purchase + 332B 0% Compra de Bienes Inmuebles + none percent 70 0.0 @@ -859,7 +859,7 @@ 332 332B - + - 332c 0% transporte publico de pasajeros - purchase + 332C 0% Transporte Publico de Pasajeros + none percent 70 0.0 @@ -893,7 +893,7 @@ 332 332C - + - 332d 0% pagos en el pais por transporte de pasajeros o transporte internacional de carga, a compañias nacionales o extranjeras de aviacion o maritimas - purchase + 332D 0% Pagos en el Pais por Transporte de Pasajeros o Transporte Internacional de Carga, a Compañias Nacionales o Extranjeras de Aviacion o Maritimas + none percent 70 0.0 @@ -927,7 +927,7 @@ 332 332D - + - 332g 0% pagos con tarjeta de credito - purchase + 332G 0% Pagos con Tarjeta de Credito + none percent 70 0.0 @@ -961,7 +961,7 @@ 332 332G - + - 332i 0% pagos a través de convenios de débito (clientes ifi`s) - purchase + 332I 0% Pagos a Través de Convenios de Débito (clientes ifi`s) + none percent 70 0.0 @@ -995,7 +995,7 @@ 332 332I - + + + 343 1% Otras Retenciones Aplicables el 1% (Incluye régimen RIMPE) + none + percent + 70 + -1.0 + Otras 1% + 393 + 343 + 343 + + + + + - 343a 1% por energia electrica - purchase + 343A 1% Por Energia Electrica + none percent 70 -1.0 @@ -1030,7 +1067,7 @@ 343 343A - + - 343b 1% por actividades de construccion de obra material inmueble, urbanizacion, lotizacion o actividades similares - purchase + 343B 1% Por Actividades de Construccion de Obra Material Inmueble, Urbanizacion, Lotizacion o Actividades Similares + none percent 70 -1.0 @@ -1067,7 +1104,7 @@ 343 343B - + - 3440 2.75% otras retenciones aplicables el 2,75% - purchase + 3440 2.75% Otras Retenciones Aplicables el 2,75% + none percent 70 - -2.0 + -2.75 3440 394 3440 3440 - + - 346 1.75% microempresas (otras retenciones aplicables a otros porcentajes) - purchase + 346 1.75% Microempresas (Otras retenciones aplicables a otros porcentajes) + none percent 70 -1.75 @@ -1141,35 +1178,35 @@ 346 346 - + - 347-346 2% donaciones en dinero -impuesto a la donaciones - purchase + 347-346 2% Donaciones en Dinero -Impuesto a las Donaciones + none percent 70 -2.0 @@ -1178,7 +1215,7 @@ 346 347 - + - 501-411 22% pago al exterior - beneficios empresariales (con convenio de doble tributación) - purchase + 501-411 22% Pago al Exterior - Beneficios Empresariales (Con Convenio de Doble Tributación) + none percent 70 -22.0 @@ -1215,7 +1252,7 @@ 411 501 - + - 501-422 22% pago al exterior - beneficios empresariales (sin convenio de doble tributación) - purchase + 501-422 22% Pago al Exterior - Beneficios Empresariales (Sin Convenio de Doble Tributación) + none percent 70 -22.0 @@ -1252,7 +1289,7 @@ 422 501 - + - 502-411 22% pago al exterior - servicios empresariales (con convenio de doble tributación) - purchase + 502-411 22% Pago al Exterior - Servicios Empresariales (Con Convenio de Doble Tributación) + none percent 70 -22.0 @@ -1289,7 +1326,7 @@ 411 502 - + - 502-422 22% pago al exterior - servicios empresariales (sin convenio de doble tributación) - purchase + 502-422 22% Pago al Exterior - Servicios Empresariales (Sin Convenio de Doble Tributación) + none percent 70 -22.0 @@ -1326,7 +1363,7 @@ 422 502 - + - 509-411 22% pago al exterior - casales, derechos de autor, marcas, patentes y similares (con convenio de doble tributación) - purchase + 509-411 22% Pago al Exterior - Casales, Derechos de Autor, Marcas, Patentes y Similares (Con Convenio de Doble Tributación) + none percent 70 -22.0 @@ -1363,7 +1400,7 @@ 461 509 - + - 509-422 pago al exterior - casales, derechos de autor, marcas, patentes y similares (sin convenio de doble tributación) - purchase + 509-422 Pago al Exterior - Casales, Derechos de Autor, Marcas, Patentes y Similares (Sin Convenio de Doble Tributación) + none percent 70 -22.0 @@ -1400,7 +1437,7 @@ 472 509 - + - 511-411 22% pago al exterior - servicios profesionales independientes (con convenio de doble tributación) - purchase + 511-411 22% Pago al Exterior - Servicios Profesionales Independientes (Con Convenio de Doble Tributación) + none percent 70 -22.0 @@ -1437,7 +1474,7 @@ 461 511 - + - 512-411 22% pago al exterior - servicios profesionales dependientes (con convenio de doble tributación) - purchase + 512-411 22% Pago al Exterior - Servicios Profesionales Dependientes (Con Convenio de Doble Tributación) + none percent 70 -22.0 @@ -1474,7 +1511,7 @@ 461 512 - + - 517-411 22% pago al exterior - reembolso de gastos (con convenio de doble tributación) - purchase + 517-411 22% Pago al Exterior - Reembolso de Gastos (Con Convenio de Doble Tributación) + none percent 70 -22.0 @@ -1511,7 +1548,7 @@ 461 517 - + - 520d-411 22% pago al exterior - comisiones por exportaciones y por promocion de turismo receptivo (con convenio de doble tributación) - purchase + 520D-411 22% Pago al Exterior - Comisiones por Exportaciones y Por Promocion de Turismo Receptivo (Con Convenio de Doble Tributación) + none percent 70 -22.0 @@ -1548,7 +1585,7 @@ 461 520D - + - 522a-410 22% pago al exterior - servicios tecnicos, administrativos o de consultoria y regalias con convenio de doble tributacion (con convenio de doble tributación) - purchase + 522A-410 22% Pago al Exterior - Servicios Tecnicos, Administrativos o de Consultoria y Regalias (Con Convenio de Doble Tributación) + none percent 70 -22.0 @@ -1585,7 +1622,7 @@ 460 522A - + + + 352 En relación de Dependencia que Supera o no la Base Desgravada + percent + none + 352 + 302 + 352 + -22.0 + 352 + + 70 + + + + - 1% retenciones de la fuente - sale + 1% Retenciones de la Fuente + none percent 70 -1.0 1% - + - 1.75% retenciones de la fuente - sale + 1.75% Retenciones de la Fuente + none percent 70 -1.75 1.75% - + - 2% retenciones de la fuente - sale + 2% Retenciones de la Fuente + none percent 70 -2.0 2% - + - 2.75% retenciones de la fuente - sale + 2.75% Retenciones de la Fuente + none percent 70 -2.75 2.75% - + - 5% retenciones de la fuente - sale + 5% Retenciones de la Fuente + none percent 70 -5.0 5% - + - 8% retenciones de la fuente - sale + 8% Retenciones de la Fuente + none percent 70 -8.0 8% - + - 10% retenciones de la fuente - sale + 10% Retenciones de la Fuente + none percent 70 -10.0 10% - + - 15% retenciones de la fuente - sale + 15% Retenciones de la Fuente + none percent 70 -15.0 15% - + - 22% retenciones de la fuente - sale + 22% Retenciones de la Fuente + none percent 70 -22.0 22% - + diff --git a/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml b/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml index ebbc0f836829bb..5d9632759257b5 100644 --- a/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml +++ b/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml @@ -5,22 +5,22 @@ PURCHASE WITHHOLDS COMPUTED OVER VAT *RETENCIONES IVA COMPRAS --> - Retencion iva 10% - purchase + 10% Retención IVA + none percent 50 -10.0 RET IVA 10% 721 - + - Retencion iva 20% - purchase + 20% Retención IVA + none percent 50 -20.0 RET IVA 20% 723 - + - Retencion iva 30% - purchase + 30% Retención IVA + none percent 50 -30.0 RET IVA 30% 725 - + - Retencion iva 50% - purchase + 50% Retención IVA + none percent 50 -50.0 RET IVA 50% 727 - + - Retencion iva 70% - purchase + 70% Retención IVA + none percent 50 -70.0 RET IVA 70% 729 - + - Retencion iva 100% - purchase + 100% Retención IVA + none percent 50 -100.0 RET IVA 100% 731 - + @@ -206,22 +206,22 @@ SALES WITHHOLDS COMPUTED OVER VAT *RETENCIONES IVA VENTAS --> - Retencion iva 10% - sale + 10% Retención IVA + none percent 60 -10.0 RET IVA 10% 609 - + - Retencion iva 20% - sale + 20% Retención IVA + none percent 60 -20.0 RET IVA 20% 609 - + - Retencion iva 30% - sale + 30% Retención IVA + none percent 60 -30.0 RET IVA 30% 609 - + - Retencion iva 50% - sale + 50% Retención IVA + none percent 60 -50.0 RET IVA 50% 609 - + - Retencion iva 70% - sale + 70% Retención IVA + none percent 60 -70.0 RET IVA 70% 609 - + - Retencion iva 100% - sale + 100% Retención IVA + none percent 60 -100.0 RET IVA 100% 609 - + EC Company - 2067636473651 - A + 2067636473001 + Av. de las Americas 505 Quito diff --git a/addons/l10n_ec/migrations/3.4/post-migration.py b/addons/l10n_ec/migrations/3.4/post-migration.py new file mode 100644 index 00000000000000..4e1b248f9599ac --- /dev/null +++ b/addons/l10n_ec/migrations/3.4/post-migration.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- + +from odoo import api, SUPERUSER_ID + +def update_withhold_type(env): + # reclasifies withhold taxes into independent tax groups for sales and purchases + env.cr.execute(''' + update account_tax + set tax_group_id=t.id from (select id from account_tax_group where l10n_ec_type='withhold_vat_sale') as t + where account_tax.id in (select id from account_tax where tax_group_id in (select id from account_tax_group where l10n_ec_type='withhold_vat') and type_tax_use='sale') + ''') + env.cr.execute(''' + update account_tax + set tax_group_id=t.id from (select id from account_tax_group where l10n_ec_type='withhold_vat_purchase') as t + where account_tax.id in (select id from account_tax where tax_group_id in (select id from account_tax_group where l10n_ec_type='withhold_vat') and type_tax_use='purchase') + ''') + env.cr.execute(''' + update account_tax + set tax_group_id=t.id from (select id from account_tax_group where l10n_ec_type='withhold_income_sale') as t + where account_tax.id in (select id from account_tax where tax_group_id in (select id from account_tax_group where l10n_ec_type='withhold_income_tax') and type_tax_use='sale') + ''') + env.cr.execute(''' + update account_tax + set tax_group_id=t.id from (select id from account_tax_group where l10n_ec_type='withhold_income_purchase') as t + where account_tax.id in (select id from account_tax where tax_group_id in (select id from account_tax_group where l10n_ec_type='withhold_income_tax') and type_tax_use='purchase') + ''') + +def update_type_tax_use(env): + # sets type_tax_use = none for withholding taxes + env.cr.execute(''' + update account_tax + set type_tax_use = 'none' + where tax_group_id in (select id from account_tax_group where l10n_ec_type in ('withhold_income_purchase','withhold_vat_purchase','withhold_income_sale','withhold_vat_sale')) + ''') + +def unlink_old_withhold_group(env): + deprecated_withhold_vat_group = env.ref('l10n_ec.tax_group_withhold_vat', False) + deprecated_withhold_profit_group = env.ref('l10n_ec.tax_group_withhold_income', False) + deprecated_withhold_vat_group and deprecated_withhold_vat_group.unlink() + deprecated_withhold_profit_group and deprecated_withhold_profit_group.unlink() + +def update_vat_withhold_base_percent(env): + # For vat withhold taxes, replace factor_percent=12% with factor_percent=100% + all_companies = env['res.company'].search([]) + ecuadorian_companies = all_companies.filtered(lambda r: r.country_code == 'EC') + ecuadorian_taxes = env['account.tax'].search([('company_id', 'in', ecuadorian_companies.ids)]) + taxes_to_fix = ecuadorian_taxes.filtered(lambda x: x.tax_group_id.l10n_ec_type in ['withhold_vat_sale', 'withhold_vat_purchase']) + env.cr.execute(''' + --for invoice_tax_id + update account_tax_repartition_line + set factor_percent=100 + where factor_percent=12 + and repartition_type='tax' + and invoice_tax_id in %s + ''', [tuple(taxes_to_fix.ids)]) + env.cr.execute(''' + --for refund_tax_id + update account_tax_repartition_line + set factor_percent=100 + where factor_percent=12 + and repartition_type='tax' + and refund_tax_id in %s + ''', [tuple(taxes_to_fix.ids)]) + +def recompute_invoice_names(env): + #recomputes invoice name, as new l10n_latam_document_number prefixes has been provided in latam document type master data + all_companies = env['res.company'].search([]) + ecuadorian_companies = all_companies.filtered(lambda r: r.country_code == 'EC') + env.cr.execute(''' + --split name by space, then concatenate code prefix with last element of name + UPDATE account_move + SET name = CONCAT(doc.doc_code_prefix,' ',reverse(split_part(reverse(account_move.name), ' ', 1))) + FROM account_move am + LEFT JOIN l10n_latam_document_type doc on doc.id = am.l10n_latam_document_type_id + WHERE am.l10n_latam_document_type_id IS NOT NULL + AND am.state IN ('posted','cancel') + AND am.id = account_move.id + AND am.company_id in %s + ''', [tuple(ecuadorian_companies.ids)]) + +def migrate(cr, version): + env = api.Environment(cr, SUPERUSER_ID, {}) + update_withhold_type(env) + update_type_tax_use(env) + unlink_old_withhold_group(env) + update_vat_withhold_base_percent(env) + recompute_invoice_names(env) diff --git a/addons/l10n_ec/models/__init__.py b/addons/l10n_ec/models/__init__.py index e7991db73a20b9..41c8372cea439a 100644 --- a/addons/l10n_ec/models/__init__.py +++ b/addons/l10n_ec/models/__init__.py @@ -9,3 +9,4 @@ from . import account_tax_group from . import res_company from . import account_journal +from . import account_chart_template diff --git a/addons/l10n_ec/models/account_chart_template.py b/addons/l10n_ec/models/account_chart_template.py new file mode 100644 index 00000000000000..09ab78de4c16ed --- /dev/null +++ b/addons/l10n_ec/models/account_chart_template.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models + + +class AccountChartTemplate(models.Model): + _inherit = "account.chart.template" + + def _prepare_all_journals(self, acc_template_ref, company, journals_dict=None): + res = super(AccountChartTemplate, self)._prepare_all_journals(acc_template_ref, company, journals_dict=journals_dict) + for r in res: + if r.get('code') == 'INV': + r.update({'name': '001-001 ' + r.get('name'), + 'l10n_ec_entity': '001', + 'l10n_ec_emission': '001', + }) + return res + \ No newline at end of file diff --git a/addons/l10n_ec/models/account_journal.py b/addons/l10n_ec/models/account_journal.py index 6ee5e541317eb1..f302e6ce9b7a43 100644 --- a/addons/l10n_ec/models/account_journal.py +++ b/addons/l10n_ec/models/account_journal.py @@ -1,18 +1,21 @@ -from odoo import fields, models +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError + class AccountJournal(models.Model): _inherit = "account.journal" - l10n_ec_entity = fields.Char(string="Emission Entity", size=3, default="001") - l10n_ec_emission = fields.Char(string="Emission Point", size=3, default="001") + l10n_ec_entity = fields.Char(string="Emission Entity", size=3, copy=False) + l10n_ec_emission = fields.Char(string="Emission Point", size=3, copy=False) l10n_ec_emission_address_id = fields.Many2one( comodel_name="res.partner", string="Emission address", domain="['|', ('id', '=', company_partner_id), '&', ('id', 'child_of', company_partner_id), ('type', '!=', 'contact')]", ) + #TODO: On next release deprecate field as is it has no use l10n_ec_emission_type = fields.Selection( string="Emission type", selection=[ @@ -22,3 +25,10 @@ class AccountJournal(models.Model): ], default="electronic", ) + + @api.constrains('l10n_ec_entity', 'l10n_ec_emission') + def l10n_ec_check_moves_entity_emmision(self): + for journal in self: + if self.env['account.move'].search([('journal_id', '=', journal.id), ('posted_before', '=', True)], limit=1): + raise ValidationError(_( + 'You can not modify the field "Emission Entity or Emission Point" if there are validated invoices in this journal!')) diff --git a/addons/l10n_ec/models/account_tax_group.py b/addons/l10n_ec/models/account_tax_group.py index 2510084fb6a088..09fc7cb97c4682 100644 --- a/addons/l10n_ec/models/account_tax_group.py +++ b/addons/l10n_ec/models/account_tax_group.py @@ -4,17 +4,20 @@ from odoo import fields, models _TYPE_EC = [ - ("vat12", "VAT 12%"), - ("vat14", "VAT 14%"), - ("zero_vat", "VAT 0%"), - ("not_charged_vat", "VAT Not Charged"), - ("exempt_vat", "VAT Exempt"), - ("withhold_vat", "VAT Withhold"), - ("withhold_income_tax", "Profit Withhold"), - ("ice", "Special Consumptions Tax (ICE)"), - ("irbpnr", "Plastic Bottles (IRBPNR)"), - ("outflows_tax", "Exchange Outflows"), - ("other", "Others"), + ("vat08", "IVA 8%"), + ("vat12", "IVA 12%"), + ("vat14", "IVA 14%"), + ("zero_vat", "IVA 0%"), + ("not_charged_vat", "No Grava IVA"), + ("exempt_vat", "Exento de IVA"), + ("ice", "Impuesto a los Consumos Especiales (ICE)"), + ("irbpnr", "Botellas de Plástico (IRBPNR)"), + ("withhold_vat_sale", "Retención de IVA en Ventas"), + ("withhold_vat_purchase", "Retención de IVA en Compras"), + ("withhold_income_sale", "Retención de Renta en Ventas"), + ("withhold_income_purchase", "Retención de Renta en Compras"), + ("outflows_tax", "Impuesto a la Salida de Divisas"), + ("other", "Otros"), ] diff --git a/addons/l10n_ec/models/l10n_ec_sri_payment.py b/addons/l10n_ec/models/l10n_ec_sri_payment.py index 9ff622edf2821f..9cb96bb35b4554 100644 --- a/addons/l10n_ec/models/l10n_ec_sri_payment.py +++ b/addons/l10n_ec/models/l10n_ec_sri_payment.py @@ -8,6 +8,9 @@ class SriPayment(models.Model): _name = "l10n_ec.sri.payment" _description = "SRI Payment Method" + _order = 'active DESC, sequence, id' - name = fields.Char("Name") + sequence = fields.Integer(default=10) code = fields.Char("Code") + name = fields.Char("Name") + active = fields.Boolean(default=True) diff --git a/addons/l10n_ec/models/l10n_latam_document_type.py b/addons/l10n_ec/models/l10n_latam_document_type.py index eb6cfcef24101e..fe2edc2dec7279 100644 --- a/addons/l10n_ec/models/l10n_latam_document_type.py +++ b/addons/l10n_ec/models/l10n_latam_document_type.py @@ -11,6 +11,7 @@ class L10nLatamDocumentType(models.Model): internal_type = fields.Selection( selection_add=[ ("purchase_liquidation", "Purchase Liquidation"), + ("withhold", "Withhold"), ] ) @@ -35,5 +36,4 @@ def _format_document_number(self, document_number): _(u"Ecuadorian Document %s must be like 001-001-123456789") % (self.display_name) ) - return document_number diff --git a/addons/l10n_ec/models/res_partner.py b/addons/l10n_ec/models/res_partner.py index fda2490d62149c..2f7c18ca5d1fa3 100644 --- a/addons/l10n_ec/models/res_partner.py +++ b/addons/l10n_ec/models/res_partner.py @@ -49,9 +49,9 @@ def check_vat(self): error_message = "" if partner.l10n_latam_identification_type_id.id == it_dni.id: error_message = _("VAT %s is not valid for an Ecuadorian DNI, " - "it must be like this form 0915068258") % partner.vat + "it must be like this form 0123456782") % partner.vat if partner.l10n_latam_identification_type_id.id == it_ruc.id: error_message = _("VAT %s is not valid for an Ecuadorian company, " - "it must be like this form 0993143790001") % partner.vat + "it must be like this form 0123456782001") % partner.vat raise ValidationError(error_message) return super(ResPartner, self - ecuadorian_partners).check_vat() diff --git a/addons/l10n_ec/views/account_journal_view.xml b/addons/l10n_ec/views/account_journal_view.xml index 7427566b22c303..8a2075dae6aa95 100644 --- a/addons/l10n_ec/views/account_journal_view.xml +++ b/addons/l10n_ec/views/account_journal_view.xml @@ -7,17 +7,25 @@ + + placeholder="001" + attrs="{'invisible':['|', '|', ('country_code', '!=', 'EC'), ('l10n_latam_use_documents', '=', False), ('type', 'not in', ('sale'))], + 'required':[('country_code', '=', 'EC'), ('l10n_latam_use_documents', '=', True), ('type', '=', 'sale')]}" + /> + placeholder="001" + attrs="{'invisible':['|', '|', ('country_code', '!=', 'EC'), ('l10n_latam_use_documents', '=', False), ('type', 'not in', ('sale'))], + 'required':[('country_code', '=', 'EC'), ('l10n_latam_use_documents', '=', True), ('type', '=', 'sale')]}" + /> - + attrs="{'invisible':['|', '|', ('country_code', '!=', 'EC'), ('l10n_latam_use_documents', '=', False), ('type', 'not in', ('sale'))], + 'required':[('country_code', '=', 'EC'), ('l10n_latam_use_documents', '=', True), ('type', '=', 'sale')]}" + context="{'default_parent_id': company_partner_id, + 'default_type': 'invoice', + 'form_view_ref': 'base.view_partner_address_form' + }" + /> diff --git a/addons/l10n_ec/views/l10n_ec_sri_payment.xml b/addons/l10n_ec/views/l10n_ec_sri_payment.xml index 3915e42ef733a4..7e7b9faa77cace 100644 --- a/addons/l10n_ec/views/l10n_ec_sri_payment.xml +++ b/addons/l10n_ec/views/l10n_ec_sri_payment.xml @@ -1,12 +1,33 @@ - - l10n.ec.sri.payment.form + + + view.payment.method.form l10n_ec.sri.payment + form - - +
+ + + + + + + +
+
+
+ + + view.payment.method.tree + l10n_ec.sri.payment + tree + + + + + @@ -15,8 +36,9 @@ Payment Methods SRI l10n_ec.sri.payment tree,form +
+ groups="account.group_account_manager" parent="l10n_ec.sri_menu" sequence="3"/>
diff --git a/addons/l10n_ec/views/root_sri_menu.xml b/addons/l10n_ec/views/root_sri_menu.xml new file mode 100644 index 00000000000000..93249027ad6f07 --- /dev/null +++ b/addons/l10n_ec/views/root_sri_menu.xml @@ -0,0 +1,8 @@ + + + + From f0a5206af8002c1bc8605427ddea2396b4ff9258 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Sat, 16 Jul 2022 18:36:36 -0500 Subject: [PATCH 03/49] [IMP] Small fixes and improvements - Improved fiscal positions - Removed overkilling constraints - Removed new fields in payment methods SRI - Removed unnecesary migration scripts - Fixed Indentation - Fixed authors --- addons/l10n_ec/__manifest__.py | 2 +- .../data/account_fiscal_position_template.xml | 15 ++-- .../data/account_tax_template_vat_data.xml | 2 +- ...ount_tax_template_withhold_profit_data.xml | 12 ++-- addons/l10n_ec/data/l10n_ec.sri.payment.csv | 18 ++--- .../l10n_ec/migrations/3.4/post-migration.py | 71 ++++--------------- .../l10n_ec/models/account_chart_template.py | 1 - addons/l10n_ec/models/account_journal.py | 7 -- addons/l10n_ec/models/account_tax_group.py | 28 ++++---- addons/l10n_ec/models/l10n_ec_sri_payment.py | 4 +- addons/l10n_ec/views/account_journal_view.xml | 2 +- addons/l10n_ec/views/l10n_ec_sri_payment.xml | 3 - addons/l10n_ec/views/root_sri_menu.xml | 2 +- 13 files changed, 60 insertions(+), 107 deletions(-) diff --git a/addons/l10n_ec/__manifest__.py b/addons/l10n_ec/__manifest__.py index 039cb11ce0214e..2ebf46ff7cd277 100644 --- a/addons/l10n_ec/__manifest__.py +++ b/addons/l10n_ec/__manifest__.py @@ -32,7 +32,7 @@ * Ecuador banks * Partners: Consumidor Final, SRI, IESS, and also basic VAT validation """, - "author": "TRESCLOUD & OPA CONSULTING", + "author": "TRESCLOUD", "category": "Accounting/Localizations/Account Charts", "maintainer": "TRESCLOUD", "website": "https://www.trescloud.com", diff --git a/addons/l10n_ec/data/account_fiscal_position_template.xml b/addons/l10n_ec/data/account_fiscal_position_template.xml index e180a3a8c75d3c..9bda2e0b7175f6 100644 --- a/addons/l10n_ec/data/account_fiscal_position_template.xml +++ b/addons/l10n_ec/data/account_fiscal_position_template.xml @@ -1,11 +1,18 @@ - + + 10 - Empresa extranjera + Régimen nacional + + + - + + 20 - Persona extranjera + Régimen extranjero + + diff --git a/addons/l10n_ec/data/account_tax_template_vat_data.xml b/addons/l10n_ec/data/account_tax_template_vat_data.xml index ce033cc084b813..4dc167aefb2fb1 100644 --- a/addons/l10n_ec/data/account_tax_template_vat_data.xml +++ b/addons/l10n_ec/data/account_tax_template_vat_data.xml @@ -820,7 +820,7 @@ })]"/>
- IVA 8% + IVA 8% purchase percent 50 diff --git a/addons/l10n_ec/data/account_tax_template_withhold_profit_data.xml b/addons/l10n_ec/data/account_tax_template_withhold_profit_data.xml index f1632424956bd0..c1ac895caacd28 100644 --- a/addons/l10n_ec/data/account_tax_template_withhold_profit_data.xml +++ b/addons/l10n_ec/data/account_tax_template_withhold_profit_data.xml @@ -2,8 +2,8 @@ + PURCHASE WITHHOLDS OVER ANTICIPADED PROFIT *IMPUESTO A LA RENTA + --> 303 10% Honorarios Profesionales y Demás Pagos por Servicios Relacionados con el Titulo Profesional none @@ -745,7 +745,7 @@ })]"/> - 322 1.75% Seguros y Reaseguros (Primas y Cesiones) 1.75% + 322 1.75% Seguros y Reaseguros (Primas y Cesiones) 1.75% none percent 70 @@ -1648,7 +1648,7 @@ 'minus_report_line_ids': [ref('tax_report_line_103_460')], })]"/> - + 352 En relación de Dependencia que Supera o no la Base Desgravada percent none @@ -1686,8 +1686,8 @@ })]"/> + SALES WITHHOLDS OVER ANTICIPADED PROFIT *IMPUESTO A LA RENTA VENTA + --> 1% Retenciones de la Fuente none diff --git a/addons/l10n_ec/data/l10n_ec.sri.payment.csv b/addons/l10n_ec/data/l10n_ec.sri.payment.csv index fca90cd904c78a..b05a1acf8fa735 100755 --- a/addons/l10n_ec/data/l10n_ec.sri.payment.csv +++ b/addons/l10n_ec/data/l10n_ec.sri.payment.csv @@ -1,9 +1,9 @@ -id,sequence,code,name,active -P1,30,01,Sin utilización del sistema financiero,1 -P15,70,15,Compensación de Deudas,1 -P16,60,16,Tarjeta de Débito,1 -P17,80,17,Dinero Electrónico,0 -P18,90,18,Tarjeta de Prepago,0 -P19,50,19,Tarjeta de Crédito,1 -P20,40,20,Otros con utilización del sistema financiero,1 -P21,100,21,Endoso de Títulos,0 +id,code,name +P1,01,Sin utilización del sistema financiero +P15,15,Compensación de Deudas +P16,16,Tarjeta de Débito +P17,17,Dinero Electrónico +P18,18,Tarjeta de Prepago +P19,19,Tarjeta de Crédito +P20,20,Otros con utilización del sistema financiero +P21,21,Endoso de Títulos diff --git a/addons/l10n_ec/migrations/3.4/post-migration.py b/addons/l10n_ec/migrations/3.4/post-migration.py index 4e1b248f9599ac..8ec80eefe3c362 100644 --- a/addons/l10n_ec/migrations/3.4/post-migration.py +++ b/addons/l10n_ec/migrations/3.4/post-migration.py @@ -5,32 +5,32 @@ def update_withhold_type(env): # reclasifies withhold taxes into independent tax groups for sales and purchases env.cr.execute(''' - update account_tax - set tax_group_id=t.id from (select id from account_tax_group where l10n_ec_type='withhold_vat_sale') as t - where account_tax.id in (select id from account_tax where tax_group_id in (select id from account_tax_group where l10n_ec_type='withhold_vat') and type_tax_use='sale') + UPDATE account_tax + SET tax_group_id=t.id FROM (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_vat_sale') AS t + WHERE account_tax.id IN (SELECT id FROM account_tax WHERE tax_group_id IN (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_vat') AND type_tax_use='sale') ''') env.cr.execute(''' - update account_tax - set tax_group_id=t.id from (select id from account_tax_group where l10n_ec_type='withhold_vat_purchase') as t - where account_tax.id in (select id from account_tax where tax_group_id in (select id from account_tax_group where l10n_ec_type='withhold_vat') and type_tax_use='purchase') + UPDATE account_tax + SET tax_group_id=t.id FROM (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_vat_purchase') AS t + WHERE account_tax.id IN (SELECT id FROM account_tax WHERE tax_group_id IN (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_vat') AND type_tax_use='purchase') ''') env.cr.execute(''' - update account_tax - set tax_group_id=t.id from (select id from account_tax_group where l10n_ec_type='withhold_income_sale') as t - where account_tax.id in (select id from account_tax where tax_group_id in (select id from account_tax_group where l10n_ec_type='withhold_income_tax') and type_tax_use='sale') + UPDATE account_tax + SET tax_group_id=t.id FROM (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_income_sale') AS t + WHERE account_tax.id IN (SELECT id FROM account_tax WHERE tax_group_id IN (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_income_tax') AND type_tax_use='sale') ''') env.cr.execute(''' - update account_tax - set tax_group_id=t.id from (select id from account_tax_group where l10n_ec_type='withhold_income_purchase') as t - where account_tax.id in (select id from account_tax where tax_group_id in (select id from account_tax_group where l10n_ec_type='withhold_income_tax') and type_tax_use='purchase') + UPDATE account_tax + SET tax_group_id=t.id FROM (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_income_purchase') AS t + WHERE account_tax.id IN (SELECT id FROM account_tax WHERE tax_group_id IN (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_income_tax') AND type_tax_use='purchase') ''') def update_type_tax_use(env): # sets type_tax_use = none for withholding taxes env.cr.execute(''' - update account_tax - set type_tax_use = 'none' - where tax_group_id in (select id from account_tax_group where l10n_ec_type in ('withhold_income_purchase','withhold_vat_purchase','withhold_income_sale','withhold_vat_sale')) + UPDATE account_tax + SET type_tax_use = 'none' + WHERE tax_group_id IN (SELECT id FROM account_tax_group WHERE l10n_ec_type IN ('withhold_income_purchase','withhold_vat_purchase','withhold_income_sale','withhold_vat_sale')) ''') def unlink_old_withhold_group(env): @@ -39,49 +39,8 @@ def unlink_old_withhold_group(env): deprecated_withhold_vat_group and deprecated_withhold_vat_group.unlink() deprecated_withhold_profit_group and deprecated_withhold_profit_group.unlink() -def update_vat_withhold_base_percent(env): - # For vat withhold taxes, replace factor_percent=12% with factor_percent=100% - all_companies = env['res.company'].search([]) - ecuadorian_companies = all_companies.filtered(lambda r: r.country_code == 'EC') - ecuadorian_taxes = env['account.tax'].search([('company_id', 'in', ecuadorian_companies.ids)]) - taxes_to_fix = ecuadorian_taxes.filtered(lambda x: x.tax_group_id.l10n_ec_type in ['withhold_vat_sale', 'withhold_vat_purchase']) - env.cr.execute(''' - --for invoice_tax_id - update account_tax_repartition_line - set factor_percent=100 - where factor_percent=12 - and repartition_type='tax' - and invoice_tax_id in %s - ''', [tuple(taxes_to_fix.ids)]) - env.cr.execute(''' - --for refund_tax_id - update account_tax_repartition_line - set factor_percent=100 - where factor_percent=12 - and repartition_type='tax' - and refund_tax_id in %s - ''', [tuple(taxes_to_fix.ids)]) - -def recompute_invoice_names(env): - #recomputes invoice name, as new l10n_latam_document_number prefixes has been provided in latam document type master data - all_companies = env['res.company'].search([]) - ecuadorian_companies = all_companies.filtered(lambda r: r.country_code == 'EC') - env.cr.execute(''' - --split name by space, then concatenate code prefix with last element of name - UPDATE account_move - SET name = CONCAT(doc.doc_code_prefix,' ',reverse(split_part(reverse(account_move.name), ' ', 1))) - FROM account_move am - LEFT JOIN l10n_latam_document_type doc on doc.id = am.l10n_latam_document_type_id - WHERE am.l10n_latam_document_type_id IS NOT NULL - AND am.state IN ('posted','cancel') - AND am.id = account_move.id - AND am.company_id in %s - ''', [tuple(ecuadorian_companies.ids)]) - def migrate(cr, version): env = api.Environment(cr, SUPERUSER_ID, {}) update_withhold_type(env) update_type_tax_use(env) unlink_old_withhold_group(env) - update_vat_withhold_base_percent(env) - recompute_invoice_names(env) diff --git a/addons/l10n_ec/models/account_chart_template.py b/addons/l10n_ec/models/account_chart_template.py index 09ab78de4c16ed..f1acc8dbb9d08d 100644 --- a/addons/l10n_ec/models/account_chart_template.py +++ b/addons/l10n_ec/models/account_chart_template.py @@ -16,4 +16,3 @@ def _prepare_all_journals(self, acc_template_ref, company, journals_dict=None): 'l10n_ec_emission': '001', }) return res - \ No newline at end of file diff --git a/addons/l10n_ec/models/account_journal.py b/addons/l10n_ec/models/account_journal.py index f302e6ce9b7a43..c700b72597e9fc 100644 --- a/addons/l10n_ec/models/account_journal.py +++ b/addons/l10n_ec/models/account_journal.py @@ -25,10 +25,3 @@ class AccountJournal(models.Model): ], default="electronic", ) - - @api.constrains('l10n_ec_entity', 'l10n_ec_emission') - def l10n_ec_check_moves_entity_emmision(self): - for journal in self: - if self.env['account.move'].search([('journal_id', '=', journal.id), ('posted_before', '=', True)], limit=1): - raise ValidationError(_( - 'You can not modify the field "Emission Entity or Emission Point" if there are validated invoices in this journal!')) diff --git a/addons/l10n_ec/models/account_tax_group.py b/addons/l10n_ec/models/account_tax_group.py index 09fc7cb97c4682..c0ca32ab0b912a 100644 --- a/addons/l10n_ec/models/account_tax_group.py +++ b/addons/l10n_ec/models/account_tax_group.py @@ -4,20 +4,20 @@ from odoo import fields, models _TYPE_EC = [ - ("vat08", "IVA 8%"), - ("vat12", "IVA 12%"), - ("vat14", "IVA 14%"), - ("zero_vat", "IVA 0%"), - ("not_charged_vat", "No Grava IVA"), - ("exempt_vat", "Exento de IVA"), - ("ice", "Impuesto a los Consumos Especiales (ICE)"), - ("irbpnr", "Botellas de Plástico (IRBPNR)"), - ("withhold_vat_sale", "Retención de IVA en Ventas"), - ("withhold_vat_purchase", "Retención de IVA en Compras"), - ("withhold_income_sale", "Retención de Renta en Ventas"), - ("withhold_income_purchase", "Retención de Renta en Compras"), - ("outflows_tax", "Impuesto a la Salida de Divisas"), - ("other", "Otros"), + ("vat08", "VAT 8%"), + ("vat12", "VAT 12%"), + ("vat14", "VAT 14%"), + ("zero_vat", "VAT 0%"), + ("not_charged_vat", "VAT Not Charged"), + ("exempt_vat", "VAT Exempt"), + ("ice", "Special Consumptions Tax (ICE)"), + ("irbpnr", "Plastic Bottles (IRBPNR)"), + ("withhold_vat_sale", "VAT Withhold on Sales"), + ("withhold_vat_purchase", "VAT Withhold on Purchases"), + ("withhold_income_sale", "Profit Withhold on Sales"), + ("withhold_income_purchase", "Profit Withhold on Purchases"), + ("outflows_tax", "Exchange Outflows"), + ("other", "Others"), ] diff --git a/addons/l10n_ec/models/l10n_ec_sri_payment.py b/addons/l10n_ec/models/l10n_ec_sri_payment.py index 9cb96bb35b4554..1bfe7a637627ff 100644 --- a/addons/l10n_ec/models/l10n_ec_sri_payment.py +++ b/addons/l10n_ec/models/l10n_ec_sri_payment.py @@ -8,9 +8,7 @@ class SriPayment(models.Model): _name = "l10n_ec.sri.payment" _description = "SRI Payment Method" - _order = 'active DESC, sequence, id' - sequence = fields.Integer(default=10) code = fields.Char("Code") name = fields.Char("Name") - active = fields.Boolean(default=True) + \ No newline at end of file diff --git a/addons/l10n_ec/views/account_journal_view.xml b/addons/l10n_ec/views/account_journal_view.xml index 8a2075dae6aa95..ee597f9adda033 100644 --- a/addons/l10n_ec/views/account_journal_view.xml +++ b/addons/l10n_ec/views/account_journal_view.xml @@ -7,7 +7,7 @@ - + - @@ -24,10 +23,8 @@ tree - - diff --git a/addons/l10n_ec/views/root_sri_menu.xml b/addons/l10n_ec/views/root_sri_menu.xml index 93249027ad6f07..3ae2b0eee0929a 100644 --- a/addons/l10n_ec/views/root_sri_menu.xml +++ b/addons/l10n_ec/views/root_sri_menu.xml @@ -1,6 +1,6 @@ - Date: Sat, 16 Jul 2022 19:47:40 -0500 Subject: [PATCH 04/49] [FIX] More fixes! --- .../l10n_ec/data/account_tax_group_data.xml | 2 +- .../data/account_tax_template_vat_data.xml | 2 +- .../l10n_ec/data/l10n_latam.document.type.csv | 76 +++++++++---------- .../l10n_ec/migrations/3.4/post-migration.py | 2 +- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/addons/l10n_ec/data/account_tax_group_data.xml b/addons/l10n_ec/data/account_tax_group_data.xml index 2a150b1d2d8beb..0da687bb6d5aab 100644 --- a/addons/l10n_ec/data/account_tax_group_data.xml +++ b/addons/l10n_ec/data/account_tax_group_data.xml @@ -82,7 +82,7 @@ Profit Withhold on Purchases withhold_income_purchase - 90 + 95 diff --git a/addons/l10n_ec/data/account_tax_template_vat_data.xml b/addons/l10n_ec/data/account_tax_template_vat_data.xml index 4dc167aefb2fb1..3f010896c43942 100644 --- a/addons/l10n_ec/data/account_tax_template_vat_data.xml +++ b/addons/l10n_ec/data/account_tax_template_vat_data.xml @@ -355,7 +355,7 @@ })]"/> - + IVA 8% sale percent diff --git a/addons/l10n_ec/data/l10n_latam.document.type.csv b/addons/l10n_ec/data/l10n_latam.document.type.csv index 676ae3cc0fb8b0..875488221450fa 100644 --- a/addons/l10n_ec/data/l10n_latam.document.type.csv +++ b/addons/l10n_ec/data/l10n_latam.document.type.csv @@ -1,38 +1,38 @@ -id,sequence,code,name,report_name,internal_type,doc_code_prefix,country_id/id,active,l10n_ec_check_format -ec_dt_01,1,01,Factura de compra,Factura de compra,invoice,Fact,base.ec,1,1 -ec_dt_02,2,02,Nota o boleta de venta,Nota o boleta de venta,invoice,Not,base.ec,1,1 -ec_dt_03,3,03,Liquidación de compra de Bienes o Prestación de servicios,Liquidación de compra de Bienes o Prestación de servicios,purchase_liquidation,LiqCo,base.ec,1,1 -ec_dt_04,4,04,Nota de Crédito,Nota de Crédito,credit_note,NotCr,base.ec,1,1 -ec_dt_05,5,05,Nota de Débito,Nota de Débito,debit_note,NotDb,base.ec,1,1 -ec_dt_08,6,08,Boletos o entradas a espectáculos públicos,Boletos o entradas a espectáculos públicos,invoice,Ent,base.ec,1,0 -ec_dt_09,7,09,Tiquetes o vales emitidos por máquinas registradoras,Tiquetes o vales emitidos por máquinas registradoras,invoice,Tiq,base.ec,1,0 -ec_dt_11,8,11,Pasajes expedidos por empresas de aviación,Pasajes expedidos por empresas de aviación,invoice,Pas,base.ec,1,0 -ec_dt_12,9,12,Documentos emitidos por instituciones financieras,Documentos emitidos por instituciones financieras,invoice,Fin,base.ec,1,0 -ec_dt_15,10,15,Comprobantes de venta emitidos en exterior,Comprobantes de venta emitidos en exterior,invoice,FacExt,base.ec,1,0 -ec_dt_16,11,16,Formulario Único de Exportación (FUE) o Declaración Aduanera Única (DAU) o Declaración Andina de Valor (DAV),Formulario Único de Exportación (FUE) o Declaración Aduanera Única (DAU) o Declaración Andina de Valor (DAV),invoice,DAU,base.ec,1,0 -ec_dt_18,12,18,Factura de venta,Factura de venta,invoice,Fact,base.ec,1,1 -ec_dt_19,13,19,Comprobantes de Pago de Cuotas o Aportes,Comprobantes de Pago de Cuotas o Aportes,invoice,Aprt,base.ec,1,0 -ec_dt_20,14,20,Documentos por Servicios Administrativos emitidos por Inst. del Estado,Documentos por Servicios Administrativos emitidos por Inst. del Estado,invoice,Gov,base.ec,1,0 -ec_dt_21,15,21,Carta de Porte Aéreo,Carta de Porte Aéreo,invoice,Aér,base.ec,1,0 -ec_dt_22,16,22,RECAP,RECAP,invoice,RECAP,base.ec,0,0 -ec_dt_23,17,23,Nota de Crédito TC,Nota de Crédito TC,credit_note,NotCrTC,base.ec,0,1 -ec_dt_24,18,24,Nota de Débito TC,Nota de Débito TC,debit_note,NotDbTC,base.ec,0,1 -ec_dt_41,19,41,Comprobante de venta emitido por reembolso,Comprobante de venta emitido por reembolso,invoice,Fact,base.ec,0,0 -ec_dt_42,20,42,Documento retención presuntiva y retención emitida por propio vendedor o por intermediario,Documento retención presuntiva y retención emitida por propio vendedor o por intermediario,invoice,Doc,base.ec,0,0 -ec_dt_43,21,43,Liquidacion para Explotacion y Exploracion de Hidrocarburos,Liquidacion para Explotacion y Exploracion de Hidrocarburos,invoice,Doc,base.ec,0,0 -ec_dt_44,22,44,Comprobante de Contribuciones y Aportes,Comprobante de Contribuciones y Aportes,invoice,Contrib,base.ec,0,0 -ec_dt_45,23,45,Liquidación por reclamos de aseguradoras,Liquidación por reclamos de aseguradoras,purchase_liquidation,LiqAseg,base.ec,0,0 -ec_dt_47,24,47,N/C por Reembolso Emitida por Intermediario,N/C por Reembolso Emitida por Intermediario,credit_note,NotCr,base.ec,0,1 -ec_dt_48,25,48,N/D por Reembolso Emitida por Intermediario,N/D por Reembolso Emitida por Intermediario,debit_note,NotDb,base.ec,0,1 -ec_dt_49,26,49,Proveedor Directo de Exportador Bajo Régimen Especial,Proveedor Directo de Exportador Bajo Régimen Especial,invoice,Doc,base.ec,0,0 -ec_dt_50,27,50,A Inst. Estado y Empr. Públicas que percibe ingreso exento de Imp. Renta,A Inst. Estado y Empr. Públicas que percibe ingreso exento de Imp. Renta,invoice,Doc,base.ec,0,0 -ec_dt_51,28,51,N/C A Inst. Estado y Empr. Públicas que percibe ingreso exento de Imp. Renta,N/C A Inst. Estado y Empr. Públicas que percibe ingreso exento de Imp. Renta,credit_note,Doc,base.ec,0,1 -ec_dt_52,29,52,N/D A Inst. Estado y Empr. Públicas que percibe ingreso exento de Imp. Renta,N/D A Inst. Estado y Empr. Públicas que percibe ingreso exento de Imp. Renta,debit_note,Doc,base.ec,0,1 -ec_dt_294,30,294,Liquidación de compra de Bienes Muebles Usados,Liquidación de compra de Bienes Muebles Usados,purchase_liquidation,LiqCo,base.ec,0,0 -ec_dt_344,31,344,Liquidación de compra de vehículos usados,Liquidación de compra de vehículos usados,purchase_liquidation,LiqCo,base.ec,0,0 -ec_dt_364,32,364,Acta Entrega-Recepción PET,Acta Entrega-Recepción PET,invoice,Rpet,base.ec,0,0 -ec_dt_370,33,370,Factura operadora transporte / socio,Factura operadora transporte / socio,invoice,Fact,base.ec,0,0 -ec_dt_371,34,371,Comprobante socio a operadora de transporte,Comprobante socio a operadora de transporte,invoice,Fact,base.ec,0,0 -ec_dt_372,35,372,Nota de crédito operadora transporte / socio,Nota de crédito operadora transporte / socio,credit_note,NotCr,base.ec,0,0 -ec_dt_373,36,373,Nota de débito operadora transporte / socio,Nota de débito operadora transporte / socio,debit_note,NotDb,base.ec,0,0 -ec_dt_07,37,07,Retención,Comprobante de Retención,withhold,Ret,base.ec,1,1 +"id","sequence","code","name","report_name","internal_type","doc_code_prefix","country_id/id","active","l10n_ec_check_format" +"ec_dt_01",1,"01","Factura de compra","Factura","invoice","Fact","base.ec",1,1 +"ec_dt_02",2,"02","Nota o boleta de venta","Nota o boleta de venta","invoice","Not","base.ec",1,1 +"ec_dt_03",3,"03","Liquidación de compra de Bienes o Prestación de servicios","Liquidación de compra de Bienes o Prestación de servicios","purchase_liquidation","LiqCo","base.ec",1,1 +"ec_dt_04",4,"04","Nota de Crédito","Nota de Crédito","credit_note","NotCr","base.ec",1,1 +"ec_dt_05",5,"05","Nota de Débito","Nota de Débito","debit_note","NotDb","base.ec",1,1 +"ec_dt_08",6,"08","Boletos o entradas a espectáculos públicos","Boletos o entradas a espectáculos públicos","invoice","Ent","base.ec",1,0 +"ec_dt_09",7,"09","Tiquetes o vales emitidos por máquinas registradoras","Tiquetes o vales emitidos por máquinas registradoras","invoice","Tiq","base.ec",1,0 +"ec_dt_11",8,"11","Pasajes expedidos por empresas de aviación","Pasajes expedidos por empresas de aviación","invoice","Pas","base.ec",1,0 +"ec_dt_12",9,"12","Documentos emitidos por instituciones financieras","Documentos emitidos por instituciones financieras","invoice","Fin","base.ec",1,0 +"ec_dt_15",10,"15","Comprobantes de venta emitidos en exterior","Comprobantes de venta emitidos en exterior","invoice","FacExt","base.ec",1,0 +"ec_dt_16",11,"16","Formulario Único de Exportación (FUE) o Declaración Aduanera Única (DAU) o Declaración Andina de Valor (DAV)","Formulario Único de Exportación (FUE) o Declaración Aduanera Única (DAU) o Declaración Andina de Valor (DAV)","invoice","DAU","base.ec",1,0 +"ec_dt_18",12,"18","Factura de venta","Factura de venta","invoice","Fact","base.ec",1,1 +"ec_dt_19",13,"19","Comprobantes de Pago de Cuotas o Aportes","Comprobantes de Pago de Cuotas o Aportes","invoice","Aprt","base.ec",1,0 +"ec_dt_20",14,"20","Documentos por Servicios Administrativos emitidos por Inst. del Estado","Documentos por Servicios Administrativos emitidos por Inst. del Estado","invoice","Gov","base.ec",1,0 +"ec_dt_21",15,"21","Carta de Porte Aéreo","Carta de Porte Aéreo","invoice","Aér","base.ec",1,0 +"ec_dt_22",16,"22","RECAP","RECAP","invoice","RECAP","base.ec",0,0 +"ec_dt_23",17,"23","Nota de Crédito TC","Nota de Crédito TC","credit_note","NotCrTC","base.ec",0,1 +"ec_dt_24",18,"24","Nota de Débito TC","Nota de Débito TC","debit_note","NotDbTC","base.ec",0,1 +"ec_dt_41",19,"41","Comprobante de venta emitido por reembolso","Comprobante de venta emitido por reembolso","invoice","Fact","base.ec",0,0 +"ec_dt_42",20,"42","Documento retención presuntiva y retención emitida por propio vendedor o por intermediario","Documento retención presuntiva y retención emitida por propio vendedor o por intermediario","invoice","Doc","base.ec",0,0 +"ec_dt_43",21,"43","Liquidacion para Explotacion y Exploracion de Hidrocarburos","Liquidacion para Explotacion y Exploracion de Hidrocarburos","invoice","Doc","base.ec",0,0 +"ec_dt_44",22,"44","Comprobante de Contribuciones y Aportes","Comprobante de Contribuciones y Aportes","invoice","Contrib","base.ec",0,0 +"ec_dt_45",23,"45","Liquidación por reclamos de aseguradoras","Liquidación por reclamos de aseguradoras","purchase_liquidation","LiqAseg","base.ec",0,0 +"ec_dt_47",24,"47","N/C por Reembolso Emitida por Intermediario","N/C por Reembolso Emitida por Intermediario","credit_note","NotCr","base.ec",0,1 +"ec_dt_48",25,"48","N/D por Reembolso Emitida por Intermediario","N/D por Reembolso Emitida por Intermediario","debit_note","NotDb","base.ec",0,1 +"ec_dt_49",26,"49","Proveedor Directo de Exportador Bajo Régimen Especial","Proveedor Directo de Exportador Bajo Régimen Especial","invoice","Doc","base.ec",0,0 +"ec_dt_50",27,"50","A Inst. Estado y Empr. Públicas que percibe ingreso exento de Imp. Renta","A Inst. Estado y Empr. Públicas que percibe ingreso exento de Imp. Renta","invoice","Doc","base.ec",0,0 +"ec_dt_51",28,"51","N/C A Inst. Estado y Empr. Públicas que percibe ingreso exento de Imp. Renta","N/C A Inst. Estado y Empr. Públicas que percibe ingreso exento de Imp. Renta","credit_note","Doc","base.ec",0,1 +"ec_dt_52",29,"52","N/D A Inst. Estado y Empr. Públicas que percibe ingreso exento de Imp. Renta","N/D A Inst. Estado y Empr. Públicas que percibe ingreso exento de Imp. Renta","debit_note","Doc","base.ec",0,1 +"ec_dt_294",30,"294","Liquidación de compra de Bienes Muebles Usados","Liquidación de compra de Bienes Muebles Usados","purchase_liquidation","LiqCo","base.ec",0,0 +"ec_dt_344",31,"344","Liquidación de compra de vehículos usados","Liquidación de compra de vehículos usados","purchase_liquidation","LiqCo","base.ec",0,0 +"ec_dt_364",32,"364","Acta Entrega-Recepción PET","Acta Entrega-Recepción PET","invoice","Rpet","base.ec",0,0 +"ec_dt_370",33,"370","Factura operadora transporte / socio","Factura operadora transporte / socio","invoice","Fact","base.ec",0,0 +"ec_dt_371",34,"371","Comprobante socio a operadora de transporte","Comprobante socio a operadora de transporte","invoice","Fact","base.ec",0,0 +"ec_dt_372",35,"372","Nota de crédito operadora transporte / socio","Nota de crédito operadora transporte / socio","credit_note","NotCr","base.ec",0,0 +"ec_dt_373",36,"373","Nota de débito operadora transporte / socio","Nota de débito operadora transporte / socio","debit_note","NotDb","base.ec",0,0 +"ec_dt_07","37","07","Retención","Comprobante de Retención","withhold","Ret","base.ec",1,1 \ No newline at end of file diff --git a/addons/l10n_ec/migrations/3.4/post-migration.py b/addons/l10n_ec/migrations/3.4/post-migration.py index 8ec80eefe3c362..cb3888e38f08bf 100644 --- a/addons/l10n_ec/migrations/3.4/post-migration.py +++ b/addons/l10n_ec/migrations/3.4/post-migration.py @@ -3,7 +3,7 @@ from odoo import api, SUPERUSER_ID def update_withhold_type(env): - # reclasifies withhold taxes into independent tax groups for sales and purchases + # reclassifies withhold taxes into independent tax groups for sales and purchases env.cr.execute(''' UPDATE account_tax SET tax_group_id=t.id FROM (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_vat_sale') AS t From 6e6d1b396da1f52bab2858351b16b2d4c4ede0b8 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Sat, 16 Jul 2022 20:58:05 -0500 Subject: [PATCH 05/49] [FIX] Remove active field --- addons/l10n_ec/views/l10n_ec_sri_payment.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_ec/views/l10n_ec_sri_payment.xml b/addons/l10n_ec/views/l10n_ec_sri_payment.xml index 8412fbe2f5bd0f..61744e76a17dab 100644 --- a/addons/l10n_ec/views/l10n_ec_sri_payment.xml +++ b/addons/l10n_ec/views/l10n_ec_sri_payment.xml @@ -22,7 +22,7 @@ l10n_ec.sri.payment tree - + From 2d36a91ac702bd8ddfff1aa181c0e43e291b07ce Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Sat, 16 Jul 2022 20:59:04 -0500 Subject: [PATCH 06/49] [ADD] Support for sending withholds by email As the is_invoice trick was not authorized by Odoo, then another method should be used for sending emails from withholds --- addons/account/models/account_move.py | 6 +++++- addons/account/models/ir_actions_report.py | 2 +- addons/account/wizard/account_invoice_send.py | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index ebc5b1e4631bc2..be65f62455362b 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -3171,6 +3171,10 @@ def button_draft(self): def button_cancel(self): self.write({'auto_post': False, 'state': 'cancel'}) + def is_mail_sendable(self): + self.ensure_one() + return self.is_invoice(include_receipts=True) + def _get_mail_template(self): """ :return: the correct mail template based on the current move type @@ -3288,7 +3292,7 @@ def action_invoice_print(self): """ Print the invoice and mark it as sent, so that we can see more easily the next step of the workflow """ - if any(not move.is_invoice(include_receipts=True) for move in self): + if any(not move.is_mail_sendable() for move in self): raise UserError(_("Only invoices could be printed.")) self.filtered(lambda inv: not inv.is_move_sent).write({'is_move_sent': True}) diff --git a/addons/account/models/ir_actions_report.py b/addons/account/models/ir_actions_report.py index cd9ea71b45fe50..c1f340e9ac5074 100644 --- a/addons/account/models/ir_actions_report.py +++ b/addons/account/models/ir_actions_report.py @@ -43,7 +43,7 @@ def _render_qweb_pdf(self, res_ids=None, data=None): invoice_reports = (self.env.ref('account.account_invoices_without_payment'), self.env.ref('account.account_invoices')) if self in invoice_reports: moves = self.env['account.move'].browse(res_ids) - if any(not move.is_invoice(include_receipts=True) for move in moves): + if any(not move.is_mail_sendable() for move in moves): raise UserError(_("Only invoices could be printed.")) return super()._render_qweb_pdf(res_ids=res_ids, data=data) diff --git a/addons/account/wizard/account_invoice_send.py b/addons/account/wizard/account_invoice_send.py index 7c895d6b1cf7c1..523c843fac9a66 100644 --- a/addons/account/wizard/account_invoice_send.py +++ b/addons/account/wizard/account_invoice_send.py @@ -36,8 +36,8 @@ def default_get(self, fields): res = super(AccountInvoiceSend, self).default_get(fields) res_ids = self._context.get('active_ids') - invoices = self.env['account.move'].browse(res_ids).filtered(lambda move: move.is_invoice(include_receipts=True)) - if not invoices: + moves = self.env['account.move'].browse(res_ids).filtered(lambda move: move.is_mail_sendable()) + if not moves: raise UserError(_("You can only send invoices.")) composer = self.env['mail.compose.message'].create({ From 0b302ee20da6897f19a058d29ee5a9d10cbdfee7 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Sun, 17 Jul 2022 00:48:02 -0500 Subject: [PATCH 07/49] [FIX] Style --- addons/l10n_ec/models/account_journal.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/l10n_ec/models/account_journal.py b/addons/l10n_ec/models/account_journal.py index c700b72597e9fc..fd25c74e3ab269 100644 --- a/addons/l10n_ec/models/account_journal.py +++ b/addons/l10n_ec/models/account_journal.py @@ -1,5 +1,4 @@ -from odoo import api, fields, models, _ -from odoo.exceptions import ValidationError +from odoo import fields, models From e6d68ee0c11bc6d40cae8c0ea4dc0da7fee1b75f Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Wed, 3 Aug 2022 00:47:22 -0500 Subject: [PATCH 08/49] [IMP] Simplified journal form form emission fields --- addons/l10n_ec/models/account_journal.py | 14 +++++++++++--- addons/l10n_ec/views/account_journal_view.xml | 14 +++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/addons/l10n_ec/models/account_journal.py b/addons/l10n_ec/models/account_journal.py index fd25c74e3ab269..f1437299bd07d9 100644 --- a/addons/l10n_ec/models/account_journal.py +++ b/addons/l10n_ec/models/account_journal.py @@ -1,11 +1,19 @@ -from odoo import fields, models - +from odoo import api, fields, models class AccountJournal(models.Model): - _inherit = "account.journal" + @api.depends('type') + def _compute_l10n_ec_require_emission(self): + # True when there should be an entity and emission point + l10n_ec_require_emission = False + if self.country_code == 'EC' and self.l10n_latam_use_documents: + if self.type == 'sale': + l10n_ec_require_emission = True + self.l10n_ec_require_emission = l10n_ec_require_emission + + l10n_ec_require_emission = fields.Boolean(string='Require Emission', compute='_compute_l10n_ec_require_emission') l10n_ec_entity = fields.Char(string="Emission Entity", size=3, copy=False) l10n_ec_emission = fields.Char(string="Emission Point", size=3, copy=False) l10n_ec_emission_address_id = fields.Many2one( diff --git a/addons/l10n_ec/views/account_journal_view.xml b/addons/l10n_ec/views/account_journal_view.xml index ee597f9adda033..2a7ec9d35fe30b 100644 --- a/addons/l10n_ec/views/account_journal_view.xml +++ b/addons/l10n_ec/views/account_journal_view.xml @@ -7,20 +7,20 @@ - + Date: Wed, 3 Aug 2022 00:50:59 -0500 Subject: [PATCH 10/49] [IMP] Improved the validation of third party documents In Latam some purchase documents (such as purchase liquidation) are issued by the company as an EDI document, even more some sales documents are issued by the customer (such as the sale withhold). To easily support those scenarios we improve the logic for validation of third party documents. --- .../models/account_move.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/addons/l10n_latam_invoice_document/models/account_move.py b/addons/l10n_latam_invoice_document/models/account_move.py index 6669e0c7147574..a41fee866b9554 100644 --- a/addons/l10n_latam_invoice_document/models/account_move.py +++ b/addons/l10n_latam_invoice_document/models/account_move.py @@ -141,8 +141,8 @@ def _post(self, soft=True): @api.constrains('name', 'journal_id', 'state') def _check_unique_sequence_number(self): """ This uniqueness verification is only valid for customer invoices, and vendor bills that does not use - documents. A new constraint method _check_unique_vendor_number has been created just for validate for this purpose """ - vendor = self.filtered(lambda x: x.is_purchase_document() and x.l10n_latam_use_documents) + documents. A new constraint method _check_unique_number_by_partner has been created just for validate for this purpose """ + vendor = self.filtered(lambda x: x._should_check_unique_number_by_partner() and x.l10n_latam_use_documents) return super(AccountMove, self - vendor)._check_unique_sequence_number() @api.constrains('state', 'l10n_latam_document_type_id') @@ -203,12 +203,16 @@ def _compute_l10n_latam_document_type(self): document_types = document_types.filtered(lambda x: x.internal_type == 'debit_note') rec.l10n_latam_document_type_id = document_types and document_types[0].id - @api.constrains('name', 'partner_id', 'company_id', 'posted_before') - def _check_unique_vendor_number(self): + def _should_check_unique_number_by_partner(self): """ The constraint _check_unique_sequence_number is valid for customer bills but not valid for us on vendor bills because the uniqueness must be per partner """ + self.ensure_one() + self.is_purchase_document() + + @api.constrains('name', 'partner_id', 'company_id', 'posted_before') + def _check_unique_number_by_partner(self): for rec in self.filtered( - lambda x: x.name and x.name != '/' and x.is_purchase_document() and x.l10n_latam_use_documents + lambda x: x.name and x.name != '/' and x._should_check_unique_number_by_partner() and x.l10n_latam_use_documents and x.commercial_partner_id): domain = [ ('move_type', '=', rec.move_type), @@ -221,4 +225,9 @@ def _check_unique_vendor_number(self): ('state', '!=', 'cancel'), ] if rec.search(domain): - raise ValidationError(_('Vendor bill number must be unique per vendor and company.')) + raise ValidationError(_('Document %s must be unique per partner and company.', rec.name)) + #raise ValidationError(_('Vendor bill number must be unique per vendor and company.')) + + def _check_unique_vendor_number(self): + # for backward compatibility in custom modules in stable, should be removed in master + self._check_unique_number_by_partner() From ca235e0678aefc523630b2acdb11f7fa60db474d Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Sat, 6 Aug 2022 13:12:39 -0500 Subject: [PATCH 11/49] [FIX] Missing on change parameter --- addons/l10n_ec/models/account_journal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_ec/models/account_journal.py b/addons/l10n_ec/models/account_journal.py index f1437299bd07d9..da79e21134e3b4 100644 --- a/addons/l10n_ec/models/account_journal.py +++ b/addons/l10n_ec/models/account_journal.py @@ -4,7 +4,7 @@ class AccountJournal(models.Model): _inherit = "account.journal" - @api.depends('type') + @api.depends('type','l10n_latam_use_documents') def _compute_l10n_ec_require_emission(self): # True when there should be an entity and emission point l10n_ec_require_emission = False From 80ddacb3f0b174f375a690a3c4dcf01de3727256 Mon Sep 17 00:00:00 2001 From: Stanislas Gueniffey Date: Wed, 10 Aug 2022 16:12:11 +0200 Subject: [PATCH 12/49] [TODO] === Revert === purchase liquidations hotfix --- addons/l10n_ec/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_ec/models/account_move.py b/addons/l10n_ec/models/account_move.py index 0de1102e502487..a0b836602409bf 100644 --- a/addons/l10n_ec/models/account_move.py +++ b/addons/l10n_ec/models/account_move.py @@ -149,7 +149,7 @@ def _get_l10n_ec_identification_type(self): if is_ruc: identification_code = "01" elif is_dni: - identification_code = "02" + identification_code = "05" # TODO revert to "02" (test purposes only) else: identification_code = "03" elif move.move_type in ("out_invoice", "out_refund", "entry"): #entry for withholds From 060098572aaaf501ec5e6ffca0f64047f6fddb14 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Wed, 14 Sep 2022 01:32:34 -0500 Subject: [PATCH 13/49] [IMP] Improvement to uniqueness validation The invoice number uniqueness validation in Latam will depend mainly if the document is issued by the company or from a third party. Note that in EC, CL, PE, some electronic purchase documents can be issued by the company itself to accomodate suppliers withoud electronic documents. --- .../models/account_move.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/l10n_latam_invoice_document/models/account_move.py b/addons/l10n_latam_invoice_document/models/account_move.py index a41fee866b9554..10b7caac9daa85 100644 --- a/addons/l10n_latam_invoice_document/models/account_move.py +++ b/addons/l10n_latam_invoice_document/models/account_move.py @@ -86,7 +86,8 @@ def _compute_l10n_latam_manual_document_number(self): remaining.l10n_latam_manual_document_number = False def _is_manual_document_number(self): - return self.journal_id.type == 'purchase' + # Manual number when document is not issued by our company + return self._should_check_unique_number_by_partner() @api.depends('name') def _compute_l10n_latam_document_number(self): @@ -140,10 +141,10 @@ def _post(self, soft=True): @api.constrains('name', 'journal_id', 'state') def _check_unique_sequence_number(self): - """ This uniqueness verification is only valid for customer invoices, and vendor bills that does not use + """ This uniqueness verification was only valid for customer invoices, and vendor bills that does not use documents. A new constraint method _check_unique_number_by_partner has been created just for validate for this purpose """ - vendor = self.filtered(lambda x: x._should_check_unique_number_by_partner() and x.l10n_latam_use_documents) - return super(AccountMove, self - vendor)._check_unique_sequence_number() + by_partner = self.filtered(lambda x: x._should_check_unique_number_by_partner() and x.l10n_latam_use_documents) + return super(AccountMove, self - by_partner)._check_unique_sequence_number() @api.constrains('state', 'l10n_latam_document_type_id') def _check_l10n_latam_documents(self): @@ -207,7 +208,7 @@ def _should_check_unique_number_by_partner(self): """ The constraint _check_unique_sequence_number is valid for customer bills but not valid for us on vendor bills because the uniqueness must be per partner """ self.ensure_one() - self.is_purchase_document() + return self.is_purchase_document() @api.constrains('name', 'partner_id', 'company_id', 'posted_before') def _check_unique_number_by_partner(self): @@ -226,7 +227,6 @@ def _check_unique_number_by_partner(self): ] if rec.search(domain): raise ValidationError(_('Document %s must be unique per partner and company.', rec.name)) - #raise ValidationError(_('Vendor bill number must be unique per vendor and company.')) def _check_unique_vendor_number(self): # for backward compatibility in custom modules in stable, should be removed in master From 1ee598fc926dac400fad0adbb352f05990872554 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Wed, 14 Sep 2022 01:33:53 -0500 Subject: [PATCH 14/49] [IMP] Improvement to support any document (like purchase liquidation) It will help Odoo decide if the document should be manually numbered or auto numbered in Ecuador, usefull por purchase liquidations --- addons/l10n_ec/models/account_move.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/l10n_ec/models/account_move.py b/addons/l10n_ec/models/account_move.py index a0b836602409bf..c9a48c4100cd85 100644 --- a/addons/l10n_ec/models/account_move.py +++ b/addons/l10n_ec/models/account_move.py @@ -175,11 +175,8 @@ def _get_l10n_ec_documents_allowed(self, identification_code): def _get_l10n_ec_internal_type(self): self.ensure_one() internal_type = self.env.context.get("internal_type", "invoice") - if self.move_type in ("out_refund", "in_refund"): - internal_type = "credit_note" - if self.debit_origin_id: - internal_type = "debit_note" - return internal_type + if self.l10n_latam_document_type_id: + internal_type = self.l10n_latam_document_type_id.internal_type def _get_l10n_latam_documents_domain(self): self.ensure_one() @@ -224,7 +221,7 @@ def _get_last_sequence_domain(self, relaxed=False): "in_invoice", "in_refund", ): - where_string, param = super(AccountMove, self)._get_last_sequence_domain(False) + where_string, param = super(AccountMove, self)._get_last_sequence_domain(False) #seems duplicated code internal_type = self._get_l10n_ec_internal_type() document_types = l10n_latam_document_type_model.search([ ('internal_type', '=', internal_type), From c8d06c35acd0a6405a908c044be13958e247418e Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Wed, 14 Sep 2022 01:36:12 -0500 Subject: [PATCH 15/49] [IMP] Theorical suggestion to CL based on improvements on latam Maybe should be removed from this PR, but to illustrate the benefit of attemped change. It is a theorical change, not tested! --- addons/l10n_cl/models/account_move.py | 6 ++++-- addons/l10n_cl/views/account_move_view.xml | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/l10n_cl/models/account_move.py b/addons/l10n_cl/models/account_move.py index 071f50b1e48bce..a4a5d26d122ead 100644 --- a/addons/l10n_cl/models/account_move.py +++ b/addons/l10n_cl/models/account_move.py @@ -155,7 +155,9 @@ def _l10n_cl_include_sii(self): self.ensure_one() return self.l10n_latam_document_type_id.code in ['39', '41', '110', '111', '112', '34'] - def _is_manual_document_number(self): + def _should_check_unique_number_by_partner(self): + # EXTEND l10n_latam_invoice_document to exclude purchase liquidations + self.ensure_one() if self.journal_id.company_id.country_id.code == 'CL': return self.journal_id.type == 'purchase' and not self.l10n_latam_document_type_id._is_doc_type_vendor() - return super()._is_manual_document_number() + return super()._should_check_unique_number_by_partner() diff --git a/addons/l10n_cl/views/account_move_view.xml b/addons/l10n_cl/views/account_move_view.xml index 2d588cfe2a54a0..52aa8ee8d19131 100644 --- a/addons/l10n_cl/views/account_move_view.xml +++ b/addons/l10n_cl/views/account_move_view.xml @@ -15,6 +15,7 @@ + account.move.latam.form.inherit.l10n.cl account.move From f4abb5abbb47fa42487dc558ddc6e705559ce9d5 Mon Sep 17 00:00:00 2001 From: Stanislas Gueniffey Date: Wed, 21 Sep 2022 21:35:51 +0200 Subject: [PATCH 16/49] [BAD FIX] TODOO+ _get_l10n_ec_identification_type --- addons/l10n_ec/models/account_move.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/l10n_ec/models/account_move.py b/addons/l10n_ec/models/account_move.py index c9a48c4100cd85..6407badd6e95ac 100644 --- a/addons/l10n_ec/models/account_move.py +++ b/addons/l10n_ec/models/account_move.py @@ -150,6 +150,8 @@ def _get_l10n_ec_identification_type(self): identification_code = "01" elif is_dni: identification_code = "05" # TODO revert to "02" (test purposes only) + elif self.l10n_latam_document_type_id.internal_type == 'purchase_liquidation': # TODO review (this made the govt/XSD accept purchase liquidation XMLs) + identification_code = "08" else: identification_code = "03" elif move.move_type in ("out_invoice", "out_refund", "entry"): #entry for withholds From a03f5b5c7ab8d02882c05d330e10a2ebac9bffbd Mon Sep 17 00:00:00 2001 From: Stanislas Gueniffey Date: Fri, 30 Sep 2022 13:31:19 +0200 Subject: [PATCH 17/49] [TOREVIEW] Execute order 18 --- addons/l10n_ec/data/l10n_latam.document.type.csv | 6 +++--- addons/l10n_ec/demo/account_demo.py | 2 +- addons/l10n_ec/models/account_move.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/l10n_ec/data/l10n_latam.document.type.csv b/addons/l10n_ec/data/l10n_latam.document.type.csv index 875488221450fa..940b2092196423 100644 --- a/addons/l10n_ec/data/l10n_latam.document.type.csv +++ b/addons/l10n_ec/data/l10n_latam.document.type.csv @@ -1,5 +1,5 @@ "id","sequence","code","name","report_name","internal_type","doc_code_prefix","country_id/id","active","l10n_ec_check_format" -"ec_dt_01",1,"01","Factura de compra","Factura","invoice","Fact","base.ec",1,1 +"ec_dt_01",1,"01","Factura","Factura","invoice","Fact","base.ec",1,1 "ec_dt_02",2,"02","Nota o boleta de venta","Nota o boleta de venta","invoice","Not","base.ec",1,1 "ec_dt_03",3,"03","Liquidación de compra de Bienes o Prestación de servicios","Liquidación de compra de Bienes o Prestación de servicios","purchase_liquidation","LiqCo","base.ec",1,1 "ec_dt_04",4,"04","Nota de Crédito","Nota de Crédito","credit_note","NotCr","base.ec",1,1 @@ -10,7 +10,7 @@ "ec_dt_12",9,"12","Documentos emitidos por instituciones financieras","Documentos emitidos por instituciones financieras","invoice","Fin","base.ec",1,0 "ec_dt_15",10,"15","Comprobantes de venta emitidos en exterior","Comprobantes de venta emitidos en exterior","invoice","FacExt","base.ec",1,0 "ec_dt_16",11,"16","Formulario Único de Exportación (FUE) o Declaración Aduanera Única (DAU) o Declaración Andina de Valor (DAV)","Formulario Único de Exportación (FUE) o Declaración Aduanera Única (DAU) o Declaración Andina de Valor (DAV)","invoice","DAU","base.ec",1,0 -"ec_dt_18",12,"18","Factura de venta","Factura de venta","invoice","Fact","base.ec",1,1 +"ec_dt_18",12,"18","Factura de venta","Factura de venta","invoice","Fact","base.ec",0,1 "ec_dt_19",13,"19","Comprobantes de Pago de Cuotas o Aportes","Comprobantes de Pago de Cuotas o Aportes","invoice","Aprt","base.ec",1,0 "ec_dt_20",14,"20","Documentos por Servicios Administrativos emitidos por Inst. del Estado","Documentos por Servicios Administrativos emitidos por Inst. del Estado","invoice","Gov","base.ec",1,0 "ec_dt_21",15,"21","Carta de Porte Aéreo","Carta de Porte Aéreo","invoice","Aér","base.ec",1,0 @@ -35,4 +35,4 @@ "ec_dt_371",34,"371","Comprobante socio a operadora de transporte","Comprobante socio a operadora de transporte","invoice","Fact","base.ec",0,0 "ec_dt_372",35,"372","Nota de crédito operadora transporte / socio","Nota de crédito operadora transporte / socio","credit_note","NotCr","base.ec",0,0 "ec_dt_373",36,"373","Nota de débito operadora transporte / socio","Nota de débito operadora transporte / socio","debit_note","NotDb","base.ec",0,0 -"ec_dt_07","37","07","Retención","Comprobante de Retención","withhold","Ret","base.ec",1,1 \ No newline at end of file +"ec_dt_07","37","07","Retención","Comprobante de Retención","withhold","Ret","base.ec",1,1 diff --git a/addons/l10n_ec/demo/account_demo.py b/addons/l10n_ec/demo/account_demo.py index ad464f1d8a328b..b7d6b3483e9f68 100644 --- a/addons/l10n_ec/demo/account_demo.py +++ b/addons/l10n_ec/demo/account_demo.py @@ -15,7 +15,7 @@ def _get_demo_data_move(self): cid = self.env.company.id model, data = super()._get_demo_data_move() if self.env.company.account_fiscal_country_id.code == 'EC': - document_type = ref('l10n_ec.ec_dt_18', False) and ref('l10n_ec.ec_dt_18').id or False + document_type = ref('l10n_ec.ec_dt_18', False) and ref('l10n_ec.ec_dt_18').id or False # TODO 18 data[f'{cid}_demo_invoice_1']['l10n_latam_document_type_id'] = document_type data[f'{cid}_demo_invoice_2']['l10n_latam_document_type_id'] = document_type data[f'{cid}_demo_invoice_3']['l10n_latam_document_type_id'] = document_type diff --git a/addons/l10n_ec/models/account_move.py b/addons/l10n_ec/models/account_move.py index 6407badd6e95ac..2d429377551101 100644 --- a/addons/l10n_ec/models/account_move.py +++ b/addons/l10n_ec/models/account_move.py @@ -48,7 +48,7 @@ "04": [ 'ec_dt_04', 'ec_dt_05', - 'ec_dt_18', + 'ec_dt_18', # TODO 18 'ec_dt_41', 'ec_dt_44', 'ec_dt_47', @@ -65,7 +65,7 @@ "05": [ 'ec_dt_04', 'ec_dt_05', - 'ec_dt_18', + 'ec_dt_18', # TODO 18 'ec_dt_41', 'ec_dt_44', 'ec_dt_47', @@ -78,7 +78,7 @@ "06": [ 'ec_dt_04', 'ec_dt_05', - 'ec_dt_18', + 'ec_dt_18', # TODO 18 'ec_dt_41', 'ec_dt_44', 'ec_dt_47', @@ -91,7 +91,7 @@ "07": [ 'ec_dt_04', 'ec_dt_05', - 'ec_dt_18' + 'ec_dt_18', # TODO 18 ], "09": [ 'ec_dt_01', From b70cc13ac48905e666e00cb6fb0dc5498c6329bb Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Sun, 2 Oct 2022 18:30:38 -0500 Subject: [PATCH 18/49] [IMP] Improve suggested withhold algorith --- .../l10n_ec/data/account_tax_template_withhold_vat_data.xml | 4 ++-- .../l10n_latam_invoice_document/views/account_move_view.xml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml b/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml index 5d9632759257b5..df070a38344e63 100644 --- a/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml +++ b/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml @@ -187,7 +187,7 @@ (0,0, { 'factor_percent': 100, 'repartition_type': 'tax', - 'account_id': ref('l10n_ec.ec_vat_withhold_70'), + 'account_id': ref('l10n_ec.ec_vat_withhold_100'), 'plus_report_line_ids': [ref('tax_report_line_104_731')], }),]"/> diff --git a/addons/l10n_latam_invoice_document/views/account_move_view.xml b/addons/l10n_latam_invoice_document/views/account_move_view.xml index 751abf90a0873e..1fb13bfc53a23b 100644 --- a/addons/l10n_latam_invoice_document/views/account_move_view.xml +++ b/addons/l10n_latam_invoice_document/views/account_move_view.xml @@ -46,7 +46,8 @@ domain="[('id', 'in', l10n_latam_available_document_type_ids)]" options="{'no_open': True, 'no_create': True}"/> From d1775bf416efeb7306a9a7264aaec95d1b1d0632 Mon Sep 17 00:00:00 2001 From: Juan Daniel Alvarez <55715973+DanielAlvarez02@users.noreply.github.com> Date: Sun, 2 Oct 2022 18:43:01 -0500 Subject: [PATCH 19/49] [ADD] Purchase VAT taxes by tax supports Adds the most common ocurrences of purchase VAT taxes by its tax support, to be easily used in withholds 2.0 --- .../l10n_ec/data/account_tax_report_data.xml | 10 + .../data/account_tax_template_vat_data.xml | 504 +++++++++++++++--- 2 files changed, 440 insertions(+), 74 deletions(-) diff --git a/addons/l10n_ec/data/account_tax_report_data.xml b/addons/l10n_ec/data/account_tax_report_data.xml index 60910f62a3a7fb..8fac2d5daf49f9 100644 --- a/addons/l10n_ec/data/account_tax_report_data.xml +++ b/addons/l10n_ec/data/account_tax_report_data.xml @@ -296,6 +296,16 @@ 1 + + Valor neto(441) + c441 + 441 (Reporte 104) + + + 1 + + + Impuesto generado(429) c429 diff --git a/addons/l10n_ec/data/account_tax_template_vat_data.xml b/addons/l10n_ec/data/account_tax_template_vat_data.xml index 3f010896c43942..2a00714956ea6e 100644 --- a/addons/l10n_ec/data/account_tax_template_vat_data.xml +++ b/addons/l10n_ec/data/account_tax_template_vat_data.xml @@ -41,6 +41,7 @@ 'minus_report_line_ids': [ref('tax_report_line_104_421')], })]"/> + IVA 12% (Activos) @@ -78,6 +79,7 @@ 'minus_report_line_ids': [ref('tax_report_line_104_422')], })]"/> + IVA 0% @@ -282,7 +284,7 @@ 'account_id': ref('l10n_ec.ec_sale_vat_services_exports'), })]"/> - + IVA 0% (No Objeto/Exentas) sale @@ -290,7 +292,7 @@ 40 0.0 IVA EXENTO - 419 + 441 @@ -298,7 +300,7 @@ (0,0, { 'factor_percent': 100, 'repartition_type': 'base', - 'plus_report_line_ids': [ref('tax_report_line_104_419')], + 'plus_report_line_ids': [ref('tax_report_line_104_441')], }), (0,0, { 'factor_percent': 100, @@ -309,7 +311,7 @@ (0,0, { 'factor_percent': 100, 'repartition_type': 'base', - 'minus_report_line_ids': [ref('tax_report_line_104_419')], + 'minus_report_line_ids': [ref('tax_report_line_104_441')], }), (0,0, { 'factor_percent': 100, @@ -333,13 +335,13 @@ (0,0, { 'factor_percent': 100, 'repartition_type': 'base', - 'plus_report_line_ids': [ref('tax_report_line_104_444')], + 'plus_report_line_ids': [ref('tax_report_line_104_412')], }), (0,0, { 'factor_percent': 100, 'repartition_type': 'tax', 'account_id': ref('l10n_ec.ec_other_downpayments'), - 'plus_report_line_ids': [ref('tax_report_line_104_454')], + 'plus_report_line_ids': [ref('tax_report_line_104_422')], })]"/> - - - - IVA 8% - sale + + + + + + + + + IVA 12% (510, 01 Crédito IVA) + purchase percent - 50 - 8.0 - IVA 8% - 411 - 421 + 9 + 12.0 + IVA 12% + 510 + 520 - + - - + + + - IVA 12% + IVA 12% (510, 05 Liq. Viaje Gasto IR) purchase percent 9 @@ -428,9 +436,164 @@ 'minus_report_line_ids': [ref('tax_report_line_104_520')], })]"/> - + + + + IVA 12% (510, 06 Inventario Crédito IVA) + purchase + percent + 9 + 12.0 + IVA 12% + 510 + 520 + + + + + + + + + IVA 12% (510, 09 Reembolso Siniestro) + purchase + percent + 9 + 12.0 + IVA 12% + 510 + 520 + + + + + + + + + IVA 12% (510, 15 Servicios Digitales) + purchase + percent + 9 + 12.0 + IVA 12% + 510 + 520 + + + + + + + + + - IVA 12% (Activos) + IVA 12% (511, 03 Activos Crédito IVA) + purchase + percent + 10 + 12.0 + IVA 12% + 511 + 521 + + + + + + + + + IVA 12% (511, 04 Activos Costo IR) purchase percent 10 @@ -465,9 +628,9 @@ 'minus_report_line_ids': [ref('tax_report_line_104_521')], })]"/> - + - IVA 12% (Sin Crédito Tributario) + IVA 12% (512, 02 Costo IR) purchase percent 10 @@ -500,9 +663,79 @@ 'minus_report_line_ids': [ref('tax_report_line_104_522')], })]"/> - + + + IVA 12% (512, 07 Inventario Costo IR) + purchase + percent + 10 + 12.0 + IVA 12% + 512 + 522 + + + + + + + + IVA 12% (512, 09 Reembolso Siniestro) + purchase + percent + 10 + 12.0 + IVA 12% + 512 + 522 + + + + + + - IVA 12% (Importación Servicios) + Iva 12% (importación servicios) purchase percent 10 @@ -537,9 +770,46 @@ 'minus_report_line_ids': [ref('tax_report_line_104_523')], })]"/> - + + + IVA 12% (514, 06 Inventario Crédito IVA) + purchase + percent + 10 + 12.0 + IVA 12% + 514 + 524 + + + + + + - IVA 12% (Importación Bienes) + IVA 12% (514, 07 Inventario Costo IR) purchase percent 10 @@ -574,9 +844,11 @@ 'minus_report_line_ids': [ref('tax_report_line_104_524')], })]"/> - + + + - IVA 12% (Importación Activos) + IVA 12% (515, 03 Activos Crédito IVA) purchase percent 10 @@ -611,9 +883,12 @@ 'minus_report_line_ids': [ref('tax_report_line_104_525')], })]"/> - + + + + - IVA 0% + IVA 0% (517, 02 Costo IR) purchase percent 20 @@ -646,22 +921,23 @@ })]"/> - - - IVA 0% (Importación Bienes) + + + + IVA 0% (517, 04 Activos Costo IR) purchase percent 20 0.0 IVA 0% - 516 + 517 + - - - IVA 0% (Rise) + + + + IVA 0% (517, 05 Liq. Viaje Gasto IR) purchase percent 20 0.0 IVA 0% - 518 + 517 + - - - IVA 0% (No Objeto de IVA) + + + + IVA 0% (517, 07 Inventario Costo IR) purchase percent - 30 + 20 0.0 - NO OBJETO DE IVA - 541 + IVA 0% + 517 - + + - - - IVA 0% (Excento de IVA) + + + + IVA 0% (517, 15 Servicios Digitales) purchase percent - 40 + 20 0.0 - IVA EXENTO - 542 + IVA 0% + 517 - + + - - - IVA 12% (Reembolso Intermediario) + + + + + + No Objeto IVA 0% (541, 02 Costo IR) purchase percent 10 @@ -803,8 +1089,7 @@ (0,0, { 'factor_percent': 100, 'repartition_type': 'tax', - 'account_id': ref('l10n_ec.ec_other_downpayments'), - 'plus_report_line_ids': [ref('tax_report_line_104_555')], + 'account_id': ref('l10n_ec.ec_purchase_vat_zero'), })]"/> + + + Exento IVA 0% (542, 02 Costo IR) + purchase + percent + 40 + 0.0 + IVA EXENTO + 542 + + + + + + + + IVA 12% (Reembolso Intermediario) + purchase + percent + 10 + 12.0 + IVA 12% + 545 + 555 + + + + + From b01e69481f033343eb743992f086f886190a730c Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Sun, 2 Oct 2022 19:51:01 -0500 Subject: [PATCH 20/49] [ADD] Adds deprecation of unused tax groups --- addons/l10n_ec/migrations/3.4/post-migration.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/l10n_ec/migrations/3.4/post-migration.py b/addons/l10n_ec/migrations/3.4/post-migration.py index cb3888e38f08bf..33ab42ece1b48b 100644 --- a/addons/l10n_ec/migrations/3.4/post-migration.py +++ b/addons/l10n_ec/migrations/3.4/post-migration.py @@ -33,14 +33,16 @@ def update_type_tax_use(env): WHERE tax_group_id IN (SELECT id FROM account_tax_group WHERE l10n_ec_type IN ('withhold_income_purchase','withhold_vat_purchase','withhold_income_sale','withhold_vat_sale')) ''') -def unlink_old_withhold_group(env): +def deprecate_old_withhold_group(env): deprecated_withhold_vat_group = env.ref('l10n_ec.tax_group_withhold_vat', False) deprecated_withhold_profit_group = env.ref('l10n_ec.tax_group_withhold_income', False) - deprecated_withhold_vat_group and deprecated_withhold_vat_group.unlink() - deprecated_withhold_profit_group and deprecated_withhold_profit_group.unlink() + if deprecated_withhold_vat_group: + deprecated_withhold_vat_group.name += ' (Deprecated)' + if deprecated_withhold_profit_group: + deprecated_withhold_profit_group += ' (Deprecated)' def migrate(cr, version): env = api.Environment(cr, SUPERUSER_ID, {}) update_withhold_type(env) update_type_tax_use(env) - unlink_old_withhold_group(env) + deprecate_old_withhold_group(env) From 4ab0cad0522ec6cf272b588e92be4a2ae9c16c55 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Sun, 2 Oct 2022 19:51:28 -0500 Subject: [PATCH 21/49] [DEL] Remove unnecesary change --- addons/l10n_ec/models/l10n_ec_sri_payment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_ec/models/l10n_ec_sri_payment.py b/addons/l10n_ec/models/l10n_ec_sri_payment.py index 1bfe7a637627ff..da3f88f0f45ea3 100644 --- a/addons/l10n_ec/models/l10n_ec_sri_payment.py +++ b/addons/l10n_ec/models/l10n_ec_sri_payment.py @@ -9,6 +9,6 @@ class SriPayment(models.Model): _name = "l10n_ec.sri.payment" _description = "SRI Payment Method" - code = fields.Char("Code") name = fields.Char("Name") + code = fields.Char("Code") \ No newline at end of file From d792614b93233bf1ea60a1c6b5d8f2e38c6db117 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Sun, 2 Oct 2022 19:57:53 -0500 Subject: [PATCH 22/49] [IMP] Removed unnecesary code Before it was calling twice to _get_last_sequence_domain(). BTW relaxed is False by default, so no need to explicit set as False --- addons/l10n_ec/models/account_move.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/addons/l10n_ec/models/account_move.py b/addons/l10n_ec/models/account_move.py index 2d429377551101..03c1677e6ee6ef 100644 --- a/addons/l10n_ec/models/account_move.py +++ b/addons/l10n_ec/models/account_move.py @@ -215,17 +215,10 @@ def _get_starting_sequence(self): return super()._get_starting_sequence() def _get_last_sequence_domain(self, relaxed=False): - l10n_latam_document_type_model = self.env['l10n_latam.document.type'] where_string, param = super(AccountMove, self)._get_last_sequence_domain(relaxed) - if self.country_code == "EC" and self.l10n_latam_use_documents and self.move_type in ( - "out_invoice", - "out_refund", - "in_invoice", - "in_refund", - ): - where_string, param = super(AccountMove, self)._get_last_sequence_domain(False) #seems duplicated code + if self.country_code == "EC" and self.l10n_latam_use_documents: internal_type = self._get_l10n_ec_internal_type() - document_types = l10n_latam_document_type_model.search([ + document_types = self.env['l10n_latam.document.type'].search([ ('internal_type', '=', internal_type), ('country_id.code', '=', 'EC'), ]) From bad1c14ca092a0c3b166ced427a7dae2af6a2cb0 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Sun, 2 Oct 2022 20:40:50 -0500 Subject: [PATCH 23/49] [IMP] Improve method name to _can_be_emailed() --- addons/account/models/account_move.py | 4 ++-- addons/account/models/ir_actions_report.py | 2 +- addons/account/wizard/account_invoice_send.py | 2 +- addons/l10n_ec/models/account_move.py | 10 ++-------- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index cc5f2adc5ac68b..77770adf40d9b4 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -3189,7 +3189,7 @@ def button_draft(self): def button_cancel(self): self.write({'auto_post': False, 'state': 'cancel'}) - def is_mail_sendable(self): + def _can_be_emailed(self): self.ensure_one() return self.is_invoice(include_receipts=True) @@ -3317,7 +3317,7 @@ def action_invoice_print(self): """ Print the invoice and mark it as sent, so that we can see more easily the next step of the workflow """ - if any(not move.is_mail_sendable() for move in self): + if any(not move._can_be_emailed() for move in self): raise UserError(_("Only invoices could be printed.")) self.filtered(lambda inv: not inv.is_move_sent).write({'is_move_sent': True}) diff --git a/addons/account/models/ir_actions_report.py b/addons/account/models/ir_actions_report.py index c1f340e9ac5074..95e2a87d74bb29 100644 --- a/addons/account/models/ir_actions_report.py +++ b/addons/account/models/ir_actions_report.py @@ -43,7 +43,7 @@ def _render_qweb_pdf(self, res_ids=None, data=None): invoice_reports = (self.env.ref('account.account_invoices_without_payment'), self.env.ref('account.account_invoices')) if self in invoice_reports: moves = self.env['account.move'].browse(res_ids) - if any(not move.is_mail_sendable() for move in moves): + if any(not move._can_be_emailed() for move in moves): raise UserError(_("Only invoices could be printed.")) return super()._render_qweb_pdf(res_ids=res_ids, data=data) diff --git a/addons/account/wizard/account_invoice_send.py b/addons/account/wizard/account_invoice_send.py index 523c843fac9a66..69bd271371d9d1 100644 --- a/addons/account/wizard/account_invoice_send.py +++ b/addons/account/wizard/account_invoice_send.py @@ -36,7 +36,7 @@ def default_get(self, fields): res = super(AccountInvoiceSend, self).default_get(fields) res_ids = self._context.get('active_ids') - moves = self.env['account.move'].browse(res_ids).filtered(lambda move: move.is_mail_sendable()) + moves = self.env['account.move'].browse(res_ids).filtered(lambda move: move._can_be_emailed()) if not moves: raise UserError(_("You can only send invoices.")) diff --git a/addons/l10n_ec/models/account_move.py b/addons/l10n_ec/models/account_move.py index 03c1677e6ee6ef..9ea6a7bbd3d1b6 100644 --- a/addons/l10n_ec/models/account_move.py +++ b/addons/l10n_ec/models/account_move.py @@ -174,12 +174,6 @@ def _get_l10n_ec_documents_allowed(self, identification_code): documents_allowed |= document_allowed return documents_allowed - def _get_l10n_ec_internal_type(self): - self.ensure_one() - internal_type = self.env.context.get("internal_type", "invoice") - if self.l10n_latam_document_type_id: - internal_type = self.l10n_latam_document_type_id.internal_type - def _get_l10n_latam_documents_domain(self): self.ensure_one() if self.journal_id.company_id.account_fiscal_country_id != self.env.ref('base.ec') or not \ @@ -189,7 +183,7 @@ def _get_l10n_latam_documents_domain(self): ('country_id.code', '=', 'EC'), ('internal_type', 'in', ['invoice', 'debit_note', 'credit_note', 'invoice_in']) ] - internal_type = self._get_l10n_ec_internal_type() + internal_type = self.l10n_latam_document_type_id.internal_type allowed_documents = self._get_l10n_ec_documents_allowed(self._get_l10n_ec_identification_type()) if internal_type and allowed_documents: domain.append(("id", "in", allowed_documents.filtered(lambda x: x.internal_type == internal_type).ids)) @@ -217,7 +211,7 @@ def _get_starting_sequence(self): def _get_last_sequence_domain(self, relaxed=False): where_string, param = super(AccountMove, self)._get_last_sequence_domain(relaxed) if self.country_code == "EC" and self.l10n_latam_use_documents: - internal_type = self._get_l10n_ec_internal_type() + internal_type = self.l10n_latam_document_type_id.internal_type document_types = self.env['l10n_latam.document.type'].search([ ('internal_type', '=', internal_type), ('country_id.code', '=', 'EC'), From a6a2ea0f1c7e643868b2219533c67011615dadd8 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Sun, 2 Oct 2022 21:35:37 -0500 Subject: [PATCH 24/49] [FIX] Cleaned up _get_l10n_ec_identification_type() --- addons/l10n_ec/models/account_move.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/addons/l10n_ec/models/account_move.py b/addons/l10n_ec/models/account_move.py index 9ea6a7bbd3d1b6..d01bebc718a9c2 100644 --- a/addons/l10n_ec/models/account_move.py +++ b/addons/l10n_ec/models/account_move.py @@ -134,7 +134,8 @@ class AccountMove(models.Model): string="Payment Method (SRI)", ) - def _get_l10n_ec_identification_type(self): + def _get_l10n_ec_ats_identification_type(self): + # Helps filter out document types based on subset of Table 2 of SRI's ATS specification self.ensure_one() move = self it_ruc = self.env.ref("l10n_ec.ec_ruc", False) @@ -149,20 +150,18 @@ def _get_l10n_ec_identification_type(self): if is_ruc: identification_code = "01" elif is_dni: - identification_code = "05" # TODO revert to "02" (test purposes only) - elif self.l10n_latam_document_type_id.internal_type == 'purchase_liquidation': # TODO review (this made the govt/XSD accept purchase liquidation XMLs) - identification_code = "08" - else: + identification_code = "02" + else: #passport or foreign ID identification_code = "03" - elif move.move_type in ("out_invoice", "out_refund", "entry"): #entry for withholds - if is_final_consumer: - identification_code = "07" - elif is_ruc: + elif move.move_type in ("out_invoice", "out_refund"): + if is_ruc: identification_code = "04" elif is_dni: identification_code = "05" - elif is_passport: + elif is_passport: #passport or foreign ID identification_code = "06" + elif is_final_consumer: + identification_code = "07" return identification_code @api.model @@ -184,7 +183,7 @@ def _get_l10n_latam_documents_domain(self): ('internal_type', 'in', ['invoice', 'debit_note', 'credit_note', 'invoice_in']) ] internal_type = self.l10n_latam_document_type_id.internal_type - allowed_documents = self._get_l10n_ec_documents_allowed(self._get_l10n_ec_identification_type()) + allowed_documents = self._get_l10n_ec_documents_allowed(self._get_l10n_ec_ats_identification_type()) if internal_type and allowed_documents: domain.append(("id", "in", allowed_documents.filtered(lambda x: x.internal_type == internal_type).ids)) return domain From 1451868ddbaa5c185613c1188e64a1c7475fcc80 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Sun, 2 Oct 2022 22:18:39 -0500 Subject: [PATCH 25/49] [FIX] Fix formatting suggestions from runbot --- addons/l10n_cl/models/account_move.py | 2 +- addons/l10n_ec/models/account_journal.py | 2 +- addons/l10n_latam_invoice_document/models/account_move.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/l10n_cl/models/account_move.py b/addons/l10n_cl/models/account_move.py index 82aec82070af3e..4e5c833a899a13 100644 --- a/addons/l10n_cl/models/account_move.py +++ b/addons/l10n_cl/models/account_move.py @@ -154,7 +154,7 @@ def _l10n_cl_include_sii(self): return self.l10n_latam_document_type_id.code in ['39', '41', '110', '111', '112', '34'] def _should_check_unique_number_by_partner(self): - # EXTEND l10n_latam_invoice_document to exclude purchase liquidations + # EXTEND l10n_latam_invoice_document to exclude purchase liquidations self.ensure_one() if self.journal_id.company_id.country_id.code == 'CL': return self.journal_id.type == 'purchase' and not self.l10n_latam_document_type_id._is_doc_type_vendor() diff --git a/addons/l10n_ec/models/account_journal.py b/addons/l10n_ec/models/account_journal.py index da79e21134e3b4..bf91d440ac3e4a 100644 --- a/addons/l10n_ec/models/account_journal.py +++ b/addons/l10n_ec/models/account_journal.py @@ -4,7 +4,7 @@ class AccountJournal(models.Model): _inherit = "account.journal" - @api.depends('type','l10n_latam_use_documents') + @api.depends('type', 'l10n_latam_use_documents') def _compute_l10n_ec_require_emission(self): # True when there should be an entity and emission point l10n_ec_require_emission = False diff --git a/addons/l10n_latam_invoice_document/models/account_move.py b/addons/l10n_latam_invoice_document/models/account_move.py index 10b7caac9daa85..e7f411a587c8f5 100644 --- a/addons/l10n_latam_invoice_document/models/account_move.py +++ b/addons/l10n_latam_invoice_document/models/account_move.py @@ -226,7 +226,7 @@ def _check_unique_number_by_partner(self): ('state', '!=', 'cancel'), ] if rec.search(domain): - raise ValidationError(_('Document %s must be unique per partner and company.', rec.name)) + raise ValidationError(_('Document %s must be unique per partner and company.', rec.name)) def _check_unique_vendor_number(self): # for backward compatibility in custom modules in stable, should be removed in master From c964e9c696bee43e2fe9f91e16752f7ef854a01a Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Mon, 3 Oct 2022 00:44:50 -0500 Subject: [PATCH 26/49] [IMP] Document types filter and replaces 18 by 01 Previously more document types than necesary where shown --- addons/l10n_ec/models/account_move.py | 28 +++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/addons/l10n_ec/models/account_move.py b/addons/l10n_ec/models/account_move.py index d01bebc718a9c2..624b2583469e98 100644 --- a/addons/l10n_ec/models/account_move.py +++ b/addons/l10n_ec/models/account_move.py @@ -46,9 +46,9 @@ 'ec_dt_344' ], "04": [ + 'ec_dt_01', 'ec_dt_04', 'ec_dt_05', - 'ec_dt_18', # TODO 18 'ec_dt_41', 'ec_dt_44', 'ec_dt_47', @@ -63,9 +63,9 @@ 'ec_dt_373' ], "05": [ + 'ec_dt_01', 'ec_dt_04', 'ec_dt_05', - 'ec_dt_18', # TODO 18 'ec_dt_41', 'ec_dt_44', 'ec_dt_47', @@ -76,9 +76,9 @@ 'ec_dt_373' ], "06": [ + 'ec_dt_01', 'ec_dt_04', 'ec_dt_05', - 'ec_dt_18', # TODO 18 'ec_dt_41', 'ec_dt_44', 'ec_dt_47', @@ -89,9 +89,9 @@ 'ec_dt_373' ], "07": [ + 'ec_dt_01', 'ec_dt_04', 'ec_dt_05', - 'ec_dt_18', # TODO 18 ], "09": [ 'ec_dt_01', @@ -175,17 +175,15 @@ def _get_l10n_ec_documents_allowed(self, identification_code): def _get_l10n_latam_documents_domain(self): self.ensure_one() - if self.journal_id.company_id.account_fiscal_country_id != self.env.ref('base.ec') or not \ - self.journal_id.l10n_latam_use_documents: - return super()._get_l10n_latam_documents_domain() - domain = [ - ('country_id.code', '=', 'EC'), - ('internal_type', 'in', ['invoice', 'debit_note', 'credit_note', 'invoice_in']) - ] - internal_type = self.l10n_latam_document_type_id.internal_type - allowed_documents = self._get_l10n_ec_documents_allowed(self._get_l10n_ec_ats_identification_type()) - if internal_type and allowed_documents: - domain.append(("id", "in", allowed_documents.filtered(lambda x: x.internal_type == internal_type).ids)) + domain = super(AccountMove, self)._get_l10n_latam_documents_domain() + if self.country_code == 'EC' and self.journal_id.l10n_latam_use_documents: + if self.debit_origin_id: # show/hide the debit note document type + domain.extend([("internal_type", "=", 'debit_note')]) + elif self.move_type in ('out_invoice','in_invoice'): + domain.extend([("internal_type", "=", 'invoice')]) + allowed_documents = self._get_l10n_ec_documents_allowed(self._get_l10n_ec_ats_identification_type()) + if allowed_documents: + domain.extend([("id", "in", allowed_documents.ids)]) return domain def _get_ec_formatted_sequence(self, number=0): From 6289252ffc31e55d8d79faedd06db942961d2f92 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Mon, 3 Oct 2022 09:54:57 -0500 Subject: [PATCH 27/49] [FIX] Formatting suggested by runbot --- addons/l10n_ec/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_ec/models/account_move.py b/addons/l10n_ec/models/account_move.py index 624b2583469e98..12e2a9b583fb57 100644 --- a/addons/l10n_ec/models/account_move.py +++ b/addons/l10n_ec/models/account_move.py @@ -179,7 +179,7 @@ def _get_l10n_latam_documents_domain(self): if self.country_code == 'EC' and self.journal_id.l10n_latam_use_documents: if self.debit_origin_id: # show/hide the debit note document type domain.extend([("internal_type", "=", 'debit_note')]) - elif self.move_type in ('out_invoice','in_invoice'): + elif self.move_type in ('out_invoice', 'in_invoice'): domain.extend([("internal_type", "=", 'invoice')]) allowed_documents = self._get_l10n_ec_documents_allowed(self._get_l10n_ec_ats_identification_type()) if allowed_documents: From 13657f7de74658a6f3f589966e274184ca110f90 Mon Sep 17 00:00:00 2001 From: Stanislas Gueniffey Date: Tue, 4 Oct 2022 11:54:00 +0200 Subject: [PATCH 28/49] [FIX] 18 is no more --- addons/l10n_ec/demo/account_demo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_ec/demo/account_demo.py b/addons/l10n_ec/demo/account_demo.py index b7d6b3483e9f68..5c7e7ff129a533 100644 --- a/addons/l10n_ec/demo/account_demo.py +++ b/addons/l10n_ec/demo/account_demo.py @@ -15,7 +15,7 @@ def _get_demo_data_move(self): cid = self.env.company.id model, data = super()._get_demo_data_move() if self.env.company.account_fiscal_country_id.code == 'EC': - document_type = ref('l10n_ec.ec_dt_18', False) and ref('l10n_ec.ec_dt_18').id or False # TODO 18 + document_type = ref('l10n_ec.ec_dt_01', False) and ref('l10n_ec.ec_dt_01').id or False data[f'{cid}_demo_invoice_1']['l10n_latam_document_type_id'] = document_type data[f'{cid}_demo_invoice_2']['l10n_latam_document_type_id'] = document_type data[f'{cid}_demo_invoice_3']['l10n_latam_document_type_id'] = document_type From 7a80bcb3f58fa40fe447932167ecc3e547caf9ee Mon Sep 17 00:00:00 2001 From: DanielAlvarez02 Date: Wed, 12 Oct 2022 16:45:22 -0500 Subject: [PATCH 29/49] [IMP] Now comments in data files are in lowercase --- .../data/account_tax_template_vat_data.xml | 68 +++++++++---------- ...ount_tax_template_withhold_profit_data.xml | 4 +- ...account_tax_template_withhold_vat_data.xml | 4 +- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/addons/l10n_ec/data/account_tax_template_vat_data.xml b/addons/l10n_ec/data/account_tax_template_vat_data.xml index 2a00714956ea6e..fccdd83c7bfbb9 100644 --- a/addons/l10n_ec/data/account_tax_template_vat_data.xml +++ b/addons/l10n_ec/data/account_tax_template_vat_data.xml @@ -2,10 +2,10 @@ - + IVA 12% sale percent @@ -43,7 +43,7 @@ - + IVA 12% (Activos) sale percent @@ -81,7 +81,7 @@ - + IVA 0% sale percent @@ -115,7 +115,7 @@ })]"/> - + IVA 0% (Activos) sale percent @@ -149,7 +149,7 @@ })]"/> - + IVA 0% (Sin Crédito Tributario) sale percent @@ -183,7 +183,7 @@ })]"/> - + IVA 0% (Activos Sin Crédito Tributario) sale percent @@ -217,7 +217,7 @@ })]"/> - + IVA 0% (Exportación Bienes) sale percent @@ -251,7 +251,7 @@ })]"/> - + IVA 0% (Exportación Servicios) sale percent @@ -285,7 +285,7 @@ })]"/> - + IVA 0% (No Objeto/Exentas) sale percent @@ -320,7 +320,7 @@ })]"/> - + IVA 12% (Reembolso) sale percent @@ -357,12 +357,12 @@ })]"/> - + - + IVA 12% (510, 01 Crédito IVA) purchase percent @@ -400,7 +400,7 @@ - + IVA 12% (510, 05 Liq. Viaje Gasto IR) purchase percent @@ -438,7 +438,7 @@ - + IVA 12% (510, 06 Inventario Crédito IVA) purchase percent @@ -476,7 +476,7 @@ - + IVA 12% (510, 09 Reembolso Siniestro) purchase percent @@ -514,7 +514,7 @@ - + IVA 12% (510, 15 Servicios Digitales) purchase percent @@ -554,7 +554,7 @@ - + IVA 12% (511, 03 Activos Crédito IVA) purchase percent @@ -592,7 +592,7 @@ - + IVA 12% (511, 04 Activos Costo IR) purchase percent @@ -629,7 +629,7 @@ })]"/> - + IVA 12% (512, 02 Costo IR) purchase percent @@ -664,7 +664,7 @@ })]"/> - + IVA 12% (512, 07 Inventario Costo IR) purchase percent @@ -699,7 +699,7 @@ })]"/> - + IVA 12% (512, 09 Reembolso Siniestro) purchase percent @@ -734,7 +734,7 @@ })]"/> - + Iva 12% (importación servicios) purchase percent @@ -771,7 +771,7 @@ })]"/> - + IVA 12% (514, 06 Inventario Crédito IVA) purchase percent @@ -808,7 +808,7 @@ })]"/> - + IVA 12% (514, 07 Inventario Costo IR) purchase percent @@ -847,7 +847,7 @@ - + IVA 12% (515, 03 Activos Crédito IVA) purchase percent @@ -887,7 +887,7 @@ - + IVA 0% (517, 02 Costo IR) purchase percent @@ -923,7 +923,7 @@ - + IVA 0% (517, 04 Activos Costo IR) purchase percent @@ -959,7 +959,7 @@ - + IVA 0% (517, 05 Liq. Viaje Gasto IR) purchase percent @@ -995,7 +995,7 @@ - + IVA 0% (517, 07 Inventario Costo IR) purchase percent @@ -1031,7 +1031,7 @@ - + IVA 0% (517, 15 Servicios Digitales) purchase percent @@ -1069,7 +1069,7 @@ - + No Objeto IVA 0% (541, 02 Costo IR) purchase percent @@ -1141,7 +1141,7 @@ })]"/> - + Exento IVA 0% (542, 02 Costo IR) purchase percent @@ -1175,7 +1175,7 @@ })]"/> - + IVA 12% (Reembolso Intermediario) purchase percent diff --git a/addons/l10n_ec/data/account_tax_template_withhold_profit_data.xml b/addons/l10n_ec/data/account_tax_template_withhold_profit_data.xml index c1ac895caacd28..f6f832d1af7bfb 100644 --- a/addons/l10n_ec/data/account_tax_template_withhold_profit_data.xml +++ b/addons/l10n_ec/data/account_tax_template_withhold_profit_data.xml @@ -2,7 +2,7 @@ 303 10% Honorarios Profesionales y Demás Pagos por Servicios Relacionados con el Titulo Profesional @@ -1686,7 +1686,7 @@ })]"/> 1% Retenciones de la Fuente diff --git a/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml b/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml index df070a38344e63..182bb3b6af6d83 100644 --- a/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml +++ b/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml @@ -2,7 +2,7 @@ 10% Retención IVA @@ -203,7 +203,7 @@ }),]"/> 10% Retención IVA From 4acd97dd095be7319f1d9b857d4951a6728342e9 Mon Sep 17 00:00:00 2001 From: DanielAlvarez02 Date: Wed, 12 Oct 2022 16:50:57 -0500 Subject: [PATCH 30/49] [IMP] Even better comments --- .../data/account_tax_template_vat_data.xml | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/addons/l10n_ec/data/account_tax_template_vat_data.xml b/addons/l10n_ec/data/account_tax_template_vat_data.xml index fccdd83c7bfbb9..d98cbeeea5fe90 100644 --- a/addons/l10n_ec/data/account_tax_template_vat_data.xml +++ b/addons/l10n_ec/data/account_tax_template_vat_data.xml @@ -2,10 +2,10 @@ - + IVA 12% sale percent @@ -43,7 +43,7 @@ - + IVA 12% (Activos) sale percent @@ -81,7 +81,7 @@ - + IVA 0% sale percent @@ -115,7 +115,7 @@ })]"/> - + IVA 0% (Activos) sale percent @@ -149,7 +149,7 @@ })]"/> - + IVA 0% (Sin Crédito Tributario) sale percent @@ -183,7 +183,7 @@ })]"/> - + IVA 0% (Activos Sin Crédito Tributario) sale percent @@ -217,7 +217,7 @@ })]"/> - + IVA 0% (Exportación Bienes) sale percent @@ -251,7 +251,7 @@ })]"/> - + IVA 0% (Exportación Servicios) sale percent @@ -285,7 +285,7 @@ })]"/> - + IVA 0% (No Objeto/Exentas) sale percent @@ -320,7 +320,7 @@ })]"/> - + IVA 12% (Reembolso) sale percent @@ -362,7 +362,7 @@ - + IVA 12% (510, 01 Crédito IVA) purchase percent @@ -400,7 +400,7 @@ - + IVA 12% (510, 05 Liq. Viaje Gasto IR) purchase percent @@ -438,7 +438,7 @@ - + IVA 12% (510, 06 Inventario Crédito IVA) purchase percent @@ -476,7 +476,7 @@ - + IVA 12% (510, 09 Reembolso Siniestro) purchase percent @@ -514,7 +514,7 @@ - + IVA 12% (510, 15 Servicios Digitales) purchase percent @@ -554,7 +554,7 @@ - + IVA 12% (511, 03 Activos Crédito IVA) purchase percent @@ -592,7 +592,7 @@ - + IVA 12% (511, 04 Activos Costo IR) purchase percent @@ -629,7 +629,7 @@ })]"/> - + IVA 12% (512, 02 Costo IR) purchase percent @@ -664,7 +664,7 @@ })]"/> - + IVA 12% (512, 07 Inventario Costo IR) purchase percent @@ -699,7 +699,7 @@ })]"/> - + IVA 12% (512, 09 Reembolso Siniestro) purchase percent @@ -734,8 +734,8 @@ })]"/> - - Iva 12% (importación servicios) + + IVA 12% (importación servicios) purchase percent 10 @@ -771,7 +771,7 @@ })]"/> - + IVA 12% (514, 06 Inventario Crédito IVA) purchase percent @@ -808,7 +808,7 @@ })]"/> - + IVA 12% (514, 07 Inventario Costo IR) purchase percent @@ -847,7 +847,7 @@ - + IVA 12% (515, 03 Activos Crédito IVA) purchase percent @@ -887,7 +887,7 @@ - + IVA 0% (517, 02 Costo IR) purchase percent @@ -923,7 +923,7 @@ - + IVA 0% (517, 04 Activos Costo IR) purchase percent @@ -959,7 +959,7 @@ - + IVA 0% (517, 05 Liq. Viaje Gasto IR) purchase percent @@ -995,7 +995,7 @@ - + IVA 0% (517, 07 Inventario Costo IR) purchase percent @@ -1031,7 +1031,7 @@ - + IVA 0% (517, 15 Servicios Digitales) purchase percent @@ -1069,7 +1069,7 @@ - + No Objeto IVA 0% (541, 02 Costo IR) purchase percent @@ -1141,7 +1141,7 @@ })]"/> - + Exento IVA 0% (542, 02 Costo IR) purchase percent @@ -1175,7 +1175,7 @@ })]"/> - + IVA 12% (Reembolso Intermediario) purchase percent From 9c28d1aa192c948087eea2ae32e51d7c24ad1446 Mon Sep 17 00:00:00 2001 From: DanielAlvarez02 Date: Wed, 12 Oct 2022 16:52:09 -0500 Subject: [PATCH 31/49] [IMP] Uppercase VAT --- .../l10n_ec/data/account_tax_template_withhold_vat_data.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml b/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml index 182bb3b6af6d83..5220577ca5e373 100644 --- a/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml +++ b/addons/l10n_ec/data/account_tax_template_withhold_vat_data.xml @@ -2,7 +2,7 @@ 10% Retención IVA @@ -203,7 +203,7 @@ }),]"/> 10% Retención IVA From 3ae39904406234bffc58962eb4c0f0e2f4c34a78 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Fri, 21 Oct 2022 05:16:00 -0500 Subject: [PATCH 32/49] [ADD] Bring back to life migration for vat withhold base For vat withhold taxes, replace factor_percent=12% with factor_percent=100% --- .../l10n_ec/migrations/3.4/post-migration.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/addons/l10n_ec/migrations/3.4/post-migration.py b/addons/l10n_ec/migrations/3.4/post-migration.py index 33ab42ece1b48b..aa1e4516998c97 100644 --- a/addons/l10n_ec/migrations/3.4/post-migration.py +++ b/addons/l10n_ec/migrations/3.4/post-migration.py @@ -41,8 +41,32 @@ def deprecate_old_withhold_group(env): if deprecated_withhold_profit_group: deprecated_withhold_profit_group += ' (Deprecated)' +def update_vat_withhold_base_percent(env): + # For vat withhold taxes, replace factor_percent=12% with factor_percent=100% + all_companies = env['res.company'].search([]) + ecuadorian_companies = all_companies.filtered(lambda r: r.country_code == 'EC') + ecuadorian_taxes = env['account.tax'].search([('company_id', 'in', ecuadorian_companies.ids)]) + taxes_to_fix = ecuadorian_taxes.filtered(lambda x: x.tax_group_id.l10n_ec_type in ['withhold_vat_sale', 'withhold_vat_purchase']) + env.cr.execute(''' + --for invoice_tax_id + update account_tax_repartition_line + set factor_percent=100 + where factor_percent=12 + and repartition_type='tax' + and invoice_tax_id in %s + ''', [tuple(taxes_to_fix.ids)]) + env.cr.execute(''' + --for refund_tax_id + update account_tax_repartition_line + set factor_percent=100 + where factor_percent=12 + and repartition_type='tax' + and refund_tax_id in %s + ''', [tuple(taxes_to_fix.ids)]) + def migrate(cr, version): env = api.Environment(cr, SUPERUSER_ID, {}) update_withhold_type(env) update_type_tax_use(env) deprecate_old_withhold_group(env) + update_vat_withhold_base_percent(env) From 5586cb6c337e7be890f90b41331e254f2de692e0 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Fri, 21 Oct 2022 05:40:26 -0500 Subject: [PATCH 33/49] [FIX] Avoid final consumer to be mixed with foreing suppliers --- addons/l10n_ec/models/account_move.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/l10n_ec/models/account_move.py b/addons/l10n_ec/models/account_move.py index 12e2a9b583fb57..c57a0ad83cf97f 100644 --- a/addons/l10n_ec/models/account_move.py +++ b/addons/l10n_ec/models/account_move.py @@ -134,6 +134,8 @@ class AccountMove(models.Model): string="Payment Method (SRI)", ) + _get_l10n_ec_identification_type = _get_l10n_ec_ats_identification_type #For backward compatibility, remove in master + def _get_l10n_ec_ats_identification_type(self): # Helps filter out document types based on subset of Table 2 of SRI's ATS specification self.ensure_one() @@ -151,7 +153,9 @@ def _get_l10n_ec_ats_identification_type(self): identification_code = "01" elif is_dni: identification_code = "02" - else: #passport or foreign ID + elif is_final_consumer: + identification_code = "07" + else: #passport or foreign ID l10n_latam_base.it_vat, identification_code = "03" elif move.move_type in ("out_invoice", "out_refund"): if is_ruc: From 91a5edc8b2cd3799a8d7c586297fe406141b141a Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Fri, 21 Oct 2022 05:40:42 -0500 Subject: [PATCH 34/49] [FIX] Remove spaces --- addons/l10n_ec/models/l10n_ec_sri_payment.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/l10n_ec/models/l10n_ec_sri_payment.py b/addons/l10n_ec/models/l10n_ec_sri_payment.py index da3f88f0f45ea3..9ff622edf2821f 100644 --- a/addons/l10n_ec/models/l10n_ec_sri_payment.py +++ b/addons/l10n_ec/models/l10n_ec_sri_payment.py @@ -11,4 +11,3 @@ class SriPayment(models.Model): name = fields.Char("Name") code = fields.Char("Code") - \ No newline at end of file From 716c5685f4e880ac7cb1d97aec99ed1234b08b14 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Fri, 21 Oct 2022 05:45:56 -0500 Subject: [PATCH 35/49] [ADD] Reincorporate old types to avoid crash if module is not updated --- addons/l10n_ec/models/account_tax_group.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/l10n_ec/models/account_tax_group.py b/addons/l10n_ec/models/account_tax_group.py index c0ca32ab0b912a..c7988c98db3a6f 100644 --- a/addons/l10n_ec/models/account_tax_group.py +++ b/addons/l10n_ec/models/account_tax_group.py @@ -18,6 +18,8 @@ ("withhold_income_purchase", "Profit Withhold on Purchases"), ("outflows_tax", "Exchange Outflows"), ("other", "Others"), + ("withhold_vat", "VAT Withhold (Deprecated)"), #remove in master + ("withhold_income_tax", "Profit Withhold (Deprecated)"), #remove in master ] From 24df0eae6ec054fb02bfdf7bad6668ca235ebd07 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Fri, 21 Oct 2022 06:02:04 -0500 Subject: [PATCH 36/49] [REF] Replace migration script with data for deprecated tax groups --- addons/l10n_ec/data/account_tax_group_data.xml | 14 ++++++++++++++ addons/l10n_ec/migrations/3.4/post-migration.py | 9 --------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/addons/l10n_ec/data/account_tax_group_data.xml b/addons/l10n_ec/data/account_tax_group_data.xml index 0da687bb6d5aab..72b0e426a05438 100644 --- a/addons/l10n_ec/data/account_tax_group_data.xml +++ b/addons/l10n_ec/data/account_tax_group_data.xml @@ -58,6 +58,20 @@ + + VAT Withhold (Deprecated) + withhold_vat + 80 + + + + + Profit Withhold (Deprecated) + withhold_income_tax + 90 + + + VAT Withhold on Sales withhold_vat_sale diff --git a/addons/l10n_ec/migrations/3.4/post-migration.py b/addons/l10n_ec/migrations/3.4/post-migration.py index aa1e4516998c97..84ffab6f390159 100644 --- a/addons/l10n_ec/migrations/3.4/post-migration.py +++ b/addons/l10n_ec/migrations/3.4/post-migration.py @@ -33,14 +33,6 @@ def update_type_tax_use(env): WHERE tax_group_id IN (SELECT id FROM account_tax_group WHERE l10n_ec_type IN ('withhold_income_purchase','withhold_vat_purchase','withhold_income_sale','withhold_vat_sale')) ''') -def deprecate_old_withhold_group(env): - deprecated_withhold_vat_group = env.ref('l10n_ec.tax_group_withhold_vat', False) - deprecated_withhold_profit_group = env.ref('l10n_ec.tax_group_withhold_income', False) - if deprecated_withhold_vat_group: - deprecated_withhold_vat_group.name += ' (Deprecated)' - if deprecated_withhold_profit_group: - deprecated_withhold_profit_group += ' (Deprecated)' - def update_vat_withhold_base_percent(env): # For vat withhold taxes, replace factor_percent=12% with factor_percent=100% all_companies = env['res.company'].search([]) @@ -68,5 +60,4 @@ def migrate(cr, version): env = api.Environment(cr, SUPERUSER_ID, {}) update_withhold_type(env) update_type_tax_use(env) - deprecate_old_withhold_group(env) update_vat_withhold_base_percent(env) From 487dd0637b55476f1dde23122f8e9822b18664e3 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Fri, 21 Oct 2022 06:38:07 -0500 Subject: [PATCH 37/49] [FIX] Changed order of method --- addons/l10n_ec/models/account_move.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/l10n_ec/models/account_move.py b/addons/l10n_ec/models/account_move.py index c57a0ad83cf97f..c9f71aa2309753 100644 --- a/addons/l10n_ec/models/account_move.py +++ b/addons/l10n_ec/models/account_move.py @@ -134,8 +134,6 @@ class AccountMove(models.Model): string="Payment Method (SRI)", ) - _get_l10n_ec_identification_type = _get_l10n_ec_ats_identification_type #For backward compatibility, remove in master - def _get_l10n_ec_ats_identification_type(self): # Helps filter out document types based on subset of Table 2 of SRI's ATS specification self.ensure_one() @@ -168,6 +166,8 @@ def _get_l10n_ec_ats_identification_type(self): identification_code = "07" return identification_code + _get_l10n_ec_identification_type = _get_l10n_ec_ats_identification_type #For backward compatibility, remove in master + @api.model def _get_l10n_ec_documents_allowed(self, identification_code): documents_allowed = self.env['l10n_latam.document.type'] From c2e01cb8875c5e78637f3b8783631227d07c11d9 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Fri, 21 Oct 2022 06:58:28 -0500 Subject: [PATCH 38/49] [ADD] Tax mapping lines for sales of goods only --- .../data/account_fiscal_position_template.xml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/l10n_ec/data/account_fiscal_position_template.xml b/addons/l10n_ec/data/account_fiscal_position_template.xml index 9bda2e0b7175f6..500c90963dda71 100644 --- a/addons/l10n_ec/data/account_fiscal_position_template.xml +++ b/addons/l10n_ec/data/account_fiscal_position_template.xml @@ -8,11 +8,21 @@ - + 20 Régimen extranjero + + + + + + + + + + From 5843718faaec1612d300219cebc2a45fd67fc77a Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Thu, 27 Oct 2022 11:56:28 -0500 Subject: [PATCH 39/49] [ADD] Split Sales VAT into goods and services --- .../data/account_fiscal_position_template.xml | 18 +++- .../data/account_tax_template_vat_data.xml | 102 +++++++++++++++--- 2 files changed, 100 insertions(+), 20 deletions(-) diff --git a/addons/l10n_ec/data/account_fiscal_position_template.xml b/addons/l10n_ec/data/account_fiscal_position_template.xml index 500c90963dda71..ef68f3c23efe4e 100644 --- a/addons/l10n_ec/data/account_fiscal_position_template.xml +++ b/addons/l10n_ec/data/account_fiscal_position_template.xml @@ -15,14 +15,24 @@ - - + + - - + + + + + + + + + + + + diff --git a/addons/l10n_ec/data/account_tax_template_vat_data.xml b/addons/l10n_ec/data/account_tax_template_vat_data.xml index d98cbeeea5fe90..32126e560cdeca 100644 --- a/addons/l10n_ec/data/account_tax_template_vat_data.xml +++ b/addons/l10n_ec/data/account_tax_template_vat_data.xml @@ -4,12 +4,49 @@ - + - IVA 12% + IVA 12% (Bienes) sale percent - 9 + 10 + 12.0 + IVA 12% + 411 + 421 + + + + + + + + IVA 12% (Servicios) + sale + percent + 20 12.0 IVA 12% 411 @@ -47,7 +84,7 @@ IVA 12% (Activos) sale percent - 10 + 30 12.0 IVA 12% 412 @@ -79,13 +116,46 @@ 'minus_report_line_ids': [ref('tax_report_line_104_422')], })]"/> - - + - IVA 0% + IVA 0% (Bienes) sale percent - 19 + 40 + 0.0 + IVA 0% + 415 + + + + + + + + IVA 0% (Servicios) + sale + percent + 50 0.0 IVA 0% 415 @@ -119,7 +189,7 @@ IVA 0% (Activos) sale percent - 20 + 60 0.0 IVA 0% 416 @@ -153,7 +223,7 @@ IVA 0% (Sin Crédito Tributario) sale percent - 20 + 70 0.0 IVA 0% 413 @@ -187,7 +257,7 @@ IVA 0% (Activos Sin Crédito Tributario) sale percent - 20 + 80 0.0 IVA 0% 414 @@ -221,7 +291,7 @@ IVA 0% (Exportación Bienes) sale percent - 21 + 90 0.0 IVA 0% 417 @@ -255,7 +325,7 @@ IVA 0% (Exportación Servicios) sale percent - 21 + 100 0.0 IVA 0% 418 @@ -289,7 +359,7 @@ IVA 0% (No Objeto/Exentas) sale percent - 40 + 110 0.0 IVA EXENTO 441 @@ -321,10 +391,10 @@ - IVA 12% (Reembolso) + IVA 12% (Reembolsos) sale percent - 10 + 120 12.0 IVA 12% 444 From 2840da64aff198799dc8e97a48f6323f1ea81ed1 Mon Sep 17 00:00:00 2001 From: JuanDanielAlvarez Date: Thu, 27 Oct 2022 13:05:18 -0500 Subject: [PATCH 40/49] [FIX] Taxes with wrong configuration, fixes to xml data --- .../l10n_ec/data/account.account.template.csv | 36 +++++++------- .../data/account_tax_template_vat_data.xml | 48 ++++--------------- 2 files changed, 27 insertions(+), 57 deletions(-) diff --git a/addons/l10n_ec/data/account.account.template.csv b/addons/l10n_ec/data/account.account.template.csv index b791c376a27a92..ab947880d93186 100644 --- a/addons/l10n_ec/data/account.account.template.csv +++ b/addons/l10n_ec/data/account.account.template.csv @@ -29,13 +29,13 @@ ec110401,110401,Seguros pagados por anticipado,TRUE,account.data_account_type_pr ec110402,110402,Arriendos pagados por anticipado,TRUE,account.data_account_type_prepayments,l10n_ec_ifrs ec110403,110403,Anticipos a proveedores,TRUE,account.data_account_type_prepayments,l10n_ec_ifrs ec_other_downpayments,11040401,Otros anticipos entregados,TRUE,account.data_account_type_prepayments,l10n_ec_ifrs -ec_purchase_vat,11050101,Iva pagado en compras locales,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs -ec_purchase_vat_assets,11050102,Iva pagado en compras locales de activos fijos,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs -ec_purchase_vat_service_imports,11050103,Iva pagado en importacion de servicios,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs -ec_purchase_vat_goods_imports,11050104,Iva pagado en importacion de bienes,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs -ec_purchase_vat_assets_imports,11050105,Iva pagado en importacion de activos fijos,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs -ec_sale_vat_outstanding_withholds,11050106,Iva pagado en retenciones de la fuente,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs -ec_purchase_vat_zero,11050107,Iva en compras 0%,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs +ec_purchase_vat,11050101,IVA pagado en compras locales,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs +ec_purchase_vat_assets,11050102,IVA pagado en compras locales de activos fijos,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs +ec_purchase_vat_service_imports,11050103,IVA pagado en importacion de servicios,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs +ec_purchase_vat_goods_imports,11050104,IVA pagado en importacion de bienes,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs +ec_purchase_vat_assets_imports,11050105,IVA pagado en importacion de activos fijos,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs +ec_sale_vat_outstanding_withholds,11050106,IVA pagado en retenciones de la fuente,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs +ec_purchase_vat_zero,11050107,IVA en compras 0%,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs ec110502,110502,Credito tributario a favor de la empresa(i.r.),FALSE,account.data_account_type_current_assets,l10n_ec_ifrs ec110503,110503,Anticipo de impuesto a la renta,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs ec_sale_profit_withhold,110504,Retenciones en la fuente pagadas,FALSE,account.data_account_type_current_assets,l10n_ec_ifrs @@ -132,11 +132,11 @@ ec2110,2110,Anticipos de clientes,TRUE,account.data_account_type_payable,l10n_ec ec2111,2111,Pasivos directamente asociados con los activos no corrientes y operaciones discontinuadas,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs ec211201,211201,Otros beneficios a largo plazo para los empleados,TRUE,account.data_account_type_payable,l10n_ec_ifrs ec211301,211301,Retenciones judiciales,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs -ec_sale_vat,2114010101,Iva cobrado en ventas locales,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs -ec_sale_vat_assets,2114010102,Iva cobrado en ventas de activos fijos,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs -ec_sale_vat_goods_exports,2114010103,Iva cobrado en exportacion de bienes,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs -ec_sale_vat_services_exports,2114010104,Iva cobrado en exportacion de servicios,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs -ec_sale_vat_zero,2114010105,Iva en ventas 0%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs +ec_sale_vat,2114010101,IVA cobrado en ventas locales,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs +ec_sale_vat_assets,2114010102,IVA cobrado en ventas de activos fijos,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs +ec_sale_vat_goods_exports,2114010103,IVA cobrado en exportacion de bienes,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs +ec_sale_vat_services_exports,2114010104,IVA cobrado en exportacion de servicios,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs +ec_sale_vat_zero,2114010105,IVA en ventas 0%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs ret_ir_1x100,2114010201,Retenciones de la fuente 1%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs ret_ir_1_75x100,2114010202,Retenciones de la fuente 1.75%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs ret_ir_2x100,2114010203,Retenciones de la fuente 2%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs @@ -147,12 +147,12 @@ ret_ir_10x100,2114010207,Retenciones de la fuente 10%,FALSE,account.data_account ret_ir_15x100,2114010208,Retenciones de la fuente 15%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs ret_ir_22x100,2114010209,Retenciones de la fuente 22%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs ret_ir_others,2114010210,Otras retenciones,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs -ec_vat_withhold_10,2114010301,Retenciones de iva 10%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs -ec_vat_withhold_20,2114010302,Retenciones de iva 20%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs -ec_vat_withhold_30,2114010303,Retenciones de iva 30%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs -ec_vat_withhold_50,2114010304,Retenciones de iva 50%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs -ec_vat_withhold_70,2114010305,Retenciones de iva 70%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs -ec_vat_withhold_100,2114010306,Retenciones de iva 100%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs +ec_vat_withhold_10,2114010301,Retenciones de IVA 10%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs +ec_vat_withhold_20,2114010302,Retenciones de IVA 20%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs +ec_vat_withhold_30,2114010303,Retenciones de IVA 30%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs +ec_vat_withhold_50,2114010304,Retenciones de IVA 50%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs +ec_vat_withhold_70,2114010305,Retenciones de IVA 70%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs +ec_vat_withhold_100,2114010306,Retenciones de IVA 100%,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs ec_vat_withhold_others,2114010307,Otras retenciones,FALSE,account.data_account_type_current_liabilities,l10n_ec_ifrs ec2201,2201,Pasivos por contratos de arrendamiento financiero,TRUE,account.data_account_type_payable,l10n_ec_ifrs ec220201,220201,Cuentas y documentos por pagar locales,TRUE,account.data_account_type_payable,l10n_ec_ifrs diff --git a/addons/l10n_ec/data/account_tax_template_vat_data.xml b/addons/l10n_ec/data/account_tax_template_vat_data.xml index 32126e560cdeca..4e8abdff38c5f5 100644 --- a/addons/l10n_ec/data/account_tax_template_vat_data.xml +++ b/addons/l10n_ec/data/account_tax_template_vat_data.xml @@ -78,7 +78,6 @@ 'minus_report_line_ids': [ref('tax_report_line_104_421')], })]"/> - IVA 12% (Activos) @@ -363,7 +362,6 @@ 0.0 IVA EXENTO 441 - - - - IVA 12% (510, 01 Crédito IVA) @@ -468,7 +463,6 @@ 'minus_report_line_ids': [ref('tax_report_line_104_520')], })]"/> - IVA 12% (510, 05 Liq. Viaje Gasto IR) @@ -506,7 +500,6 @@ 'minus_report_line_ids': [ref('tax_report_line_104_520')], })]"/> - IVA 12% (510, 06 Inventario Crédito IVA) @@ -544,7 +537,6 @@ 'minus_report_line_ids': [ref('tax_report_line_104_520')], })]"/> - IVA 12% (510, 09 Reembolso Siniestro) @@ -582,7 +574,6 @@ 'minus_report_line_ids': [ref('tax_report_line_104_520')], })]"/> - IVA 12% (510, 15 Servicios Digitales) @@ -620,9 +611,7 @@ 'minus_report_line_ids': [ref('tax_report_line_104_520')], })]"/> - - IVA 12% (511, 03 Activos Crédito IVA) @@ -660,7 +649,6 @@ 'minus_report_line_ids': [ref('tax_report_line_104_521')], })]"/> - IVA 12% (511, 04 Activos Costo IR) @@ -914,8 +902,6 @@ 'minus_report_line_ids': [ref('tax_report_line_104_524')], })]"/> - - IVA 12% (515, 03 Activos Crédito IVA) @@ -953,9 +939,7 @@ 'minus_report_line_ids': [ref('tax_report_line_104_525')], })]"/> - - IVA 0% (517, 02 Costo IR) @@ -989,9 +973,7 @@ 'repartition_type': 'tax', 'account_id': ref('l10n_ec.ec_purchase_vat_zero'), })]"/> - - IVA 0% (517, 04 Activos Costo IR) @@ -1025,9 +1007,7 @@ 'repartition_type': 'tax', 'account_id': ref('l10n_ec.ec_purchase_vat_zero'), })]"/> - - IVA 0% (517, 05 Liq. Viaje Gasto IR) @@ -1061,9 +1041,7 @@ 'repartition_type': 'tax', 'account_id': ref('l10n_ec.ec_purchase_vat_zero'), })]"/> - - IVA 0% (517, 07 Inventario Costo IR) @@ -1097,9 +1075,7 @@ 'repartition_type': 'tax', 'account_id': ref('l10n_ec.ec_purchase_vat_zero'), })]"/> - - IVA 0% (517, 15 Servicios Digitales) @@ -1133,28 +1109,23 @@ 'repartition_type': 'tax', 'account_id': ref('l10n_ec.ec_purchase_vat_zero'), })]"/> - - - No Objeto IVA 0% (541, 02 Costo IR) - purchase percent - 10 - 12.0 - IVA 12% - 545 - 555 - - + 30 + 0.0 + IVA 0% + 541 + + From d21636e1167b32692825c9ac3ed2fff4252c887a Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Thu, 27 Oct 2022 14:29:22 -0500 Subject: [PATCH 41/49] [DEL] Undo improvements in latam document type Just keep the strictly neccesary --- addons/l10n_cl/models/account_move.py | 4 ++-- addons/l10n_cl/views/account_move_view.xml | 2 +- .../models/account_move.py | 24 +++++++------------ 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/addons/l10n_cl/models/account_move.py b/addons/l10n_cl/models/account_move.py index 4e5c833a899a13..2028fb3a317a07 100644 --- a/addons/l10n_cl/models/account_move.py +++ b/addons/l10n_cl/models/account_move.py @@ -153,9 +153,9 @@ def _l10n_cl_include_sii(self): self.ensure_one() return self.l10n_latam_document_type_id.code in ['39', '41', '110', '111', '112', '34'] - def _should_check_unique_number_by_partner(self): + def _is_manual_document_number(self): # EXTEND l10n_latam_invoice_document to exclude purchase liquidations self.ensure_one() if self.journal_id.company_id.country_id.code == 'CL': return self.journal_id.type == 'purchase' and not self.l10n_latam_document_type_id._is_doc_type_vendor() - return super()._should_check_unique_number_by_partner() + return super()._is_manual_document_number() diff --git a/addons/l10n_cl/views/account_move_view.xml b/addons/l10n_cl/views/account_move_view.xml index 52aa8ee8d19131..349dd0b181c1f6 100644 --- a/addons/l10n_cl/views/account_move_view.xml +++ b/addons/l10n_cl/views/account_move_view.xml @@ -15,7 +15,7 @@ - + account.move.latam.form.inherit.l10n.cl account.move diff --git a/addons/l10n_latam_invoice_document/models/account_move.py b/addons/l10n_latam_invoice_document/models/account_move.py index e7f411a587c8f5..a8eaa05c8f813a 100644 --- a/addons/l10n_latam_invoice_document/models/account_move.py +++ b/addons/l10n_latam_invoice_document/models/account_move.py @@ -86,8 +86,8 @@ def _compute_l10n_latam_manual_document_number(self): remaining.l10n_latam_manual_document_number = False def _is_manual_document_number(self): - # Manual number when document is not issued by our company - return self._should_check_unique_number_by_partner() + # Manual number when document number is to be typed by the user, aka issued by suppliers + return self.is_purchase_document() @api.depends('name') def _compute_l10n_latam_document_number(self): @@ -142,9 +142,9 @@ def _post(self, soft=True): @api.constrains('name', 'journal_id', 'state') def _check_unique_sequence_number(self): """ This uniqueness verification was only valid for customer invoices, and vendor bills that does not use - documents. A new constraint method _check_unique_number_by_partner has been created just for validate for this purpose """ - by_partner = self.filtered(lambda x: x._should_check_unique_number_by_partner() and x.l10n_latam_use_documents) - return super(AccountMove, self - by_partner)._check_unique_sequence_number() + documents. A new constraint method _check_unique_vendor_number has been created just for validate for this purpose """ + vendor = self.filtered(lambda x: x.is_purchase_document() and x.l10n_latam_use_documents) + return super(AccountMove, self - vendor)._check_unique_sequence_number() @api.constrains('state', 'l10n_latam_document_type_id') def _check_l10n_latam_documents(self): @@ -204,16 +204,12 @@ def _compute_l10n_latam_document_type(self): document_types = document_types.filtered(lambda x: x.internal_type == 'debit_note') rec.l10n_latam_document_type_id = document_types and document_types[0].id - def _should_check_unique_number_by_partner(self): + @api.constrains('name', 'partner_id', 'company_id', 'posted_before') + def _check_unique_vendor_number(self): """ The constraint _check_unique_sequence_number is valid for customer bills but not valid for us on vendor bills because the uniqueness must be per partner """ - self.ensure_one() - return self.is_purchase_document() - - @api.constrains('name', 'partner_id', 'company_id', 'posted_before') - def _check_unique_number_by_partner(self): for rec in self.filtered( - lambda x: x.name and x.name != '/' and x._should_check_unique_number_by_partner() and x.l10n_latam_use_documents + lambda x: x.name and x.name != '/' and x._is_manual_document_number() and x.l10n_latam_use_documents and x.commercial_partner_id): domain = [ ('move_type', '=', rec.move_type), @@ -227,7 +223,3 @@ def _check_unique_number_by_partner(self): ] if rec.search(domain): raise ValidationError(_('Document %s must be unique per partner and company.', rec.name)) - - def _check_unique_vendor_number(self): - # for backward compatibility in custom modules in stable, should be removed in master - self._check_unique_number_by_partner() From 26164e8ad109c96d1d63f3d368dbb412a82f5c38 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Thu, 27 Oct 2022 15:00:56 -0500 Subject: [PATCH 42/49] [DEL] Remove comments on l10n_cl --- addons/l10n_cl/models/account_move.py | 2 -- addons/l10n_cl/views/account_move_view.xml | 1 - 2 files changed, 3 deletions(-) diff --git a/addons/l10n_cl/models/account_move.py b/addons/l10n_cl/models/account_move.py index 2028fb3a317a07..d2023d2d78e323 100644 --- a/addons/l10n_cl/models/account_move.py +++ b/addons/l10n_cl/models/account_move.py @@ -154,8 +154,6 @@ def _l10n_cl_include_sii(self): return self.l10n_latam_document_type_id.code in ['39', '41', '110', '111', '112', '34'] def _is_manual_document_number(self): - # EXTEND l10n_latam_invoice_document to exclude purchase liquidations - self.ensure_one() if self.journal_id.company_id.country_id.code == 'CL': return self.journal_id.type == 'purchase' and not self.l10n_latam_document_type_id._is_doc_type_vendor() return super()._is_manual_document_number() diff --git a/addons/l10n_cl/views/account_move_view.xml b/addons/l10n_cl/views/account_move_view.xml index 349dd0b181c1f6..2d588cfe2a54a0 100644 --- a/addons/l10n_cl/views/account_move_view.xml +++ b/addons/l10n_cl/views/account_move_view.xml @@ -15,7 +15,6 @@ - account.move.latam.form.inherit.l10n.cl account.move From e09c4b28052c305063fefbdcf01278bb58ab80ba Mon Sep 17 00:00:00 2001 From: JuanDanielAlvarez Date: Thu, 27 Oct 2022 15:04:57 -0500 Subject: [PATCH 43/49] [IMP] Cosmetic fixes to the code --- addons/l10n_cl/models/account_move.py | 2 +- addons/l10n_ec/data/account_tax_report_data.xml | 1 - addons/l10n_ec/models/account_journal.py | 2 +- addons/l10n_ec/models/l10n_latam_document_type.py | 1 + 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/l10n_cl/models/account_move.py b/addons/l10n_cl/models/account_move.py index 4e5c833a899a13..8b3e2723a7b858 100644 --- a/addons/l10n_cl/models/account_move.py +++ b/addons/l10n_cl/models/account_move.py @@ -154,7 +154,7 @@ def _l10n_cl_include_sii(self): return self.l10n_latam_document_type_id.code in ['39', '41', '110', '111', '112', '34'] def _should_check_unique_number_by_partner(self): - # EXTEND l10n_latam_invoice_document to exclude purchase liquidations + # EXTENDS l10n_latam_invoice_document to exclude purchase liquidations self.ensure_one() if self.journal_id.company_id.country_id.code == 'CL': return self.journal_id.type == 'purchase' and not self.l10n_latam_document_type_id._is_doc_type_vendor() diff --git a/addons/l10n_ec/data/account_tax_report_data.xml b/addons/l10n_ec/data/account_tax_report_data.xml index 8fac2d5daf49f9..838ec3a93a46c7 100644 --- a/addons/l10n_ec/data/account_tax_report_data.xml +++ b/addons/l10n_ec/data/account_tax_report_data.xml @@ -305,7 +305,6 @@ 1 - Impuesto generado(429) c429 diff --git a/addons/l10n_ec/models/account_journal.py b/addons/l10n_ec/models/account_journal.py index bf91d440ac3e4a..58f607152ed530 100644 --- a/addons/l10n_ec/models/account_journal.py +++ b/addons/l10n_ec/models/account_journal.py @@ -22,7 +22,7 @@ def _compute_l10n_ec_require_emission(self): domain="['|', ('id', '=', company_partner_id), '&', ('id', 'child_of', company_partner_id), ('type', '!=', 'contact')]", ) - #TODO: On next release deprecate field as is it has no use + #TODO: Deprecate field in master as is it has no use l10n_ec_emission_type = fields.Selection( string="Emission type", selection=[ diff --git a/addons/l10n_ec/models/l10n_latam_document_type.py b/addons/l10n_ec/models/l10n_latam_document_type.py index fe2edc2dec7279..8ff2f6eae8caab 100644 --- a/addons/l10n_ec/models/l10n_latam_document_type.py +++ b/addons/l10n_ec/models/l10n_latam_document_type.py @@ -36,4 +36,5 @@ def _format_document_number(self, document_number): _(u"Ecuadorian Document %s must be like 001-001-123456789") % (self.display_name) ) + return document_number From 636cfff1218409f92e12716b7495c75d39492e63 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Thu, 27 Oct 2022 15:18:59 -0500 Subject: [PATCH 44/49] [FIX] Fix _is_manual_document_number instead of is_purchase_document --- addons/l10n_latam_invoice_document/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_latam_invoice_document/models/account_move.py b/addons/l10n_latam_invoice_document/models/account_move.py index a8eaa05c8f813a..baa1a2778b4258 100644 --- a/addons/l10n_latam_invoice_document/models/account_move.py +++ b/addons/l10n_latam_invoice_document/models/account_move.py @@ -143,7 +143,7 @@ def _post(self, soft=True): def _check_unique_sequence_number(self): """ This uniqueness verification was only valid for customer invoices, and vendor bills that does not use documents. A new constraint method _check_unique_vendor_number has been created just for validate for this purpose """ - vendor = self.filtered(lambda x: x.is_purchase_document() and x.l10n_latam_use_documents) + vendor = self.filtered(lambda x: x._is_manual_document_number() and x.l10n_latam_use_documents) return super(AccountMove, self - vendor)._check_unique_sequence_number() @api.constrains('state', 'l10n_latam_document_type_id') From 4115d6599a14a122d39b44815b9c1b17039b49e7 Mon Sep 17 00:00:00 2001 From: JuanDanielAlvarez Date: Thu, 27 Oct 2022 16:04:06 -0500 Subject: [PATCH 45/49] [IMP] Import journal emission address --- addons/l10n_ec/models/account_chart_template.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/l10n_ec/models/account_chart_template.py b/addons/l10n_ec/models/account_chart_template.py index f1acc8dbb9d08d..4abbac82820705 100644 --- a/addons/l10n_ec/models/account_chart_template.py +++ b/addons/l10n_ec/models/account_chart_template.py @@ -14,5 +14,6 @@ def _prepare_all_journals(self, acc_template_ref, company, journals_dict=None): r.update({'name': '001-001 ' + r.get('name'), 'l10n_ec_entity': '001', 'l10n_ec_emission': '001', + 'l10n_ec_emission_address_id': company.partner_id.id, }) return res From 94811b2dc2e2319ea19f6d7553b0a35ff65c8c1e Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Thu, 27 Oct 2022 17:02:00 -0500 Subject: [PATCH 46/49] [IMP] Migration script should use only SQL --- .../l10n_ec/migrations/3.4/post-migration.py | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/addons/l10n_ec/migrations/3.4/post-migration.py b/addons/l10n_ec/migrations/3.4/post-migration.py index 84ffab6f390159..d9a54f92c45028 100644 --- a/addons/l10n_ec/migrations/3.4/post-migration.py +++ b/addons/l10n_ec/migrations/3.4/post-migration.py @@ -35,26 +35,36 @@ def update_type_tax_use(env): def update_vat_withhold_base_percent(env): # For vat withhold taxes, replace factor_percent=12% with factor_percent=100% - all_companies = env['res.company'].search([]) - ecuadorian_companies = all_companies.filtered(lambda r: r.country_code == 'EC') - ecuadorian_taxes = env['account.tax'].search([('company_id', 'in', ecuadorian_companies.ids)]) - taxes_to_fix = ecuadorian_taxes.filtered(lambda x: x.tax_group_id.l10n_ec_type in ['withhold_vat_sale', 'withhold_vat_purchase']) env.cr.execute(''' --for invoice_tax_id - update account_tax_repartition_line - set factor_percent=100 - where factor_percent=12 - and repartition_type='tax' - and invoice_tax_id in %s - ''', [tuple(taxes_to_fix.ids)]) + UPDATE account_tax_repartition_line + SET factor_percent = 100 + WHERE factor_percent = 12 + AND repartition_type = 'tax' + AND invoice_tax_id in ( + SELECT id + FROM account_tax + WHERE country_id = (SELECT id FROM res_country WHERE code = 'EC' LIMIT 1) --Country is Ecuador) + AND tax_group_id IN ( + SELECT id FROM account_tax_group WHERE l10n_ec_type IN ('withhold_vat_sale','withhold_vat_purchase') + ) + ) + ''') env.cr.execute(''' --for refund_tax_id - update account_tax_repartition_line - set factor_percent=100 - where factor_percent=12 - and repartition_type='tax' - and refund_tax_id in %s - ''', [tuple(taxes_to_fix.ids)]) + UPDATE account_tax_repartition_line + SET factor_percent = 100 + WHERE factor_percent = 12 + AND repartition_type = 'tax' + AND refund_tax_id in ( + SELECT id + FROM account_tax + WHERE country_id = (SELECT id FROM res_country WHERE code = 'EC' LIMIT 1) --Country is Ecuador) + AND tax_group_id IN ( + SELECT id FROM account_tax_group WHERE l10n_ec_type IN ('withhold_vat_sale','withhold_vat_purchase') + ) + ) + ''') def migrate(cr, version): env = api.Environment(cr, SUPERUSER_ID, {}) From bacbeca18e4f362cfa223702688ea8d7a79c55c7 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Thu, 27 Oct 2022 20:29:51 -0500 Subject: [PATCH 47/49] [FIX] Typos in data files --- addons/l10n_ec/data/l10n_latam_identification_type_data.xml | 2 +- addons/l10n_ec/models/res_partner.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/l10n_ec/data/l10n_latam_identification_type_data.xml b/addons/l10n_ec/data/l10n_latam_identification_type_data.xml index 604a3997ad3808..73203f592a8190 100644 --- a/addons/l10n_ec/data/l10n_latam_identification_type_data.xml +++ b/addons/l10n_ec/data/l10n_latam_identification_type_data.xml @@ -3,7 +3,7 @@ RUC - Registre Unico de Contribuyente + Registro Unico de Contribuyente 10 diff --git a/addons/l10n_ec/models/res_partner.py b/addons/l10n_ec/models/res_partner.py index 2f7c18ca5d1fa3..c383be401699ea 100644 --- a/addons/l10n_ec/models/res_partner.py +++ b/addons/l10n_ec/models/res_partner.py @@ -49,9 +49,9 @@ def check_vat(self): error_message = "" if partner.l10n_latam_identification_type_id.id == it_dni.id: error_message = _("VAT %s is not valid for an Ecuadorian DNI, " - "it must be like this form 0123456782") % partner.vat + "it must be like this form 1234567897") % partner.vat if partner.l10n_latam_identification_type_id.id == it_ruc.id: error_message = _("VAT %s is not valid for an Ecuadorian company, " - "it must be like this form 0123456782001") % partner.vat + "it must be like this form 1234567897001") % partner.vat raise ValidationError(error_message) return super(ResPartner, self - ecuadorian_partners).check_vat() From dfee677ea8daed0835acc2a45705694fd52090a6 Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Thu, 27 Oct 2022 20:32:15 -0500 Subject: [PATCH 48/49] [WIP] Improve document types domain Improve how to catch identification types for foreign companies and final consumer --- addons/l10n_ec/models/account_move.py | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/addons/l10n_ec/models/account_move.py b/addons/l10n_ec/models/account_move.py index c9f71aa2309753..152c502e649351 100644 --- a/addons/l10n_ec/models/account_move.py +++ b/addons/l10n_ec/models/account_move.py @@ -137,33 +137,33 @@ class AccountMove(models.Model): def _get_l10n_ec_ats_identification_type(self): # Helps filter out document types based on subset of Table 2 of SRI's ATS specification self.ensure_one() - move = self - it_ruc = self.env.ref("l10n_ec.ec_ruc", False) - it_dni = self.env.ref("l10n_ec.ec_dni", False) - it_passport = self.env.ref("l10n_ec.ec_passport", False) - is_final_consumer = verify_final_consumer(move.partner_id.commercial_partner_id.vat) - is_ruc = move.partner_id.commercial_partner_id.l10n_latam_identification_type_id.id == it_ruc.id - is_dni = move.partner_id.commercial_partner_id.l10n_latam_identification_type_id.id == it_dni.id - is_passport = move.partner_id.commercial_partner_id.l10n_latam_identification_type_id.id == it_passport.id + ec_ruc = self.env.ref("l10n_ec.ec_ruc", False) + ec_dni = self.env.ref("l10n_ec.ec_dni", False) + ec_passport = self.env.ref("l10n_ec.ec_passport", False) + it_pass = self.env.ref("l10n_latam_base.it_pass", False) # Passport + it_vat = self.env.ref("l10n_latam_base.it_vat", False) + it_fid = self.env.ref("l10n_latam_base.it_fid", False) # Foreign ID + # find partner identification type + is_ruc = self.partner_id.l10n_latam_identification_type_id == ec_ruc + is_dni = self.partner_id.l10n_latam_identification_type_id == ec_dni + #TODO Joss, for "is_foreign", are we sure it_vat is intended to be a foreigner? it will affect the edi module in sister method _get_l10n_ec_edi_identification_type() + is_foreign = self.partner_id.l10n_latam_identification_type_id in [ec_passport, it_pass, it_vat, it_fid] + # map identification code considering sale or purchase as per table 2 of ATS identification_code = False - if move.move_type in ("in_invoice", "in_refund"): - if is_ruc: + if self.move_type in ("in_invoice", "in_refund"): + if is_ruc: # includes final consumer identification_code = "01" elif is_dni: identification_code = "02" - elif is_final_consumer: - identification_code = "07" - else: #passport or foreign ID l10n_latam_base.it_vat, + elif is_foreign: identification_code = "03" - elif move.move_type in ("out_invoice", "out_refund"): - if is_ruc: + elif self.move_type in ("out_invoice", "out_refund"): + if is_ruc: # includes final consumer identification_code = "04" elif is_dni: identification_code = "05" - elif is_passport: #passport or foreign ID + elif is_foreign: #passport or foreign ID identification_code = "06" - elif is_final_consumer: - identification_code = "07" return identification_code _get_l10n_ec_identification_type = _get_l10n_ec_ats_identification_type #For backward compatibility, remove in master @@ -184,9 +184,9 @@ def _get_l10n_latam_documents_domain(self): if self.debit_origin_id: # show/hide the debit note document type domain.extend([("internal_type", "=", 'debit_note')]) elif self.move_type in ('out_invoice', 'in_invoice'): - domain.extend([("internal_type", "=", 'invoice')]) + domain.extend([("internal_type", "=", 'invoice')]) allowed_documents = self._get_l10n_ec_documents_allowed(self._get_l10n_ec_ats_identification_type()) - if allowed_documents: + if allowed_documents: #TODO Joss, Andres suggest to remove the condition, so that if no ID matches then no document is available domain.extend([("id", "in", allowed_documents.ids)]) return domain From 041a08a42faf8811071dc00372c880616ae5e75d Mon Sep 17 00:00:00 2001 From: Andres Calle Date: Thu, 27 Oct 2022 20:37:13 -0500 Subject: [PATCH 49/49] [FIX] Remove unneded space --- addons/l10n_ec/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_ec/models/account_move.py b/addons/l10n_ec/models/account_move.py index 152c502e649351..f3c47cadfcf35b 100644 --- a/addons/l10n_ec/models/account_move.py +++ b/addons/l10n_ec/models/account_move.py @@ -184,7 +184,7 @@ def _get_l10n_latam_documents_domain(self): if self.debit_origin_id: # show/hide the debit note document type domain.extend([("internal_type", "=", 'debit_note')]) elif self.move_type in ('out_invoice', 'in_invoice'): - domain.extend([("internal_type", "=", 'invoice')]) + domain.extend([("internal_type", "=", 'invoice')]) allowed_documents = self._get_l10n_ec_documents_allowed(self._get_l10n_ec_ats_identification_type()) if allowed_documents: #TODO Joss, Andres suggest to remove the condition, so that if no ID matches then no document is available domain.extend([("id", "in", allowed_documents.ids)])