From f1d39fb028af54e603961e7f2b639f4e4e992c1a Mon Sep 17 00:00:00 2001 From: Katherine Zaoral Date: Fri, 18 Mar 2022 14:41:53 -0300 Subject: [PATCH] [ADD] l10n_uy_account, l10n_uy_edi: journals type move the electronic integration options to the l10n_uy_edi module. Change the informatiion show about manual type in order to be use as manual or for create post morthem electrinic invoices created from external softwarw (like online invoices in AR). --- l10n_uy_account/__manifest__.py | 2 +- l10n_uy_account/i18n/es.po | 10 ---- l10n_uy_account/i18n/l10n_uy_account.pot | 10 ---- l10n_uy_account/models/account_journal.py | 30 ++++------ l10n_uy_account/models/account_move.py | 8 --- l10n_uy_edi/__manifest__.py | 2 +- l10n_uy_edi/i18n/es.po | 10 ++++ l10n_uy_edi/models/account_journal.py | 72 +++++++++++++++++------ l10n_uy_edi/models/account_move.py | 9 +++ 9 files changed, 84 insertions(+), 69 deletions(-) diff --git a/l10n_uy_account/__manifest__.py b/l10n_uy_account/__manifest__.py index f7252911..b925d310 100644 --- a/l10n_uy_account/__manifest__.py +++ b/l10n_uy_account/__manifest__.py @@ -7,7 +7,7 @@ 'author': 'ADHOC SA', 'category': 'Localization', 'license': 'LGPL-3', - 'version': '13.0.1.6.0', + 'version': '13.0.1.7.0', 'depends': [ 'l10n_latam_invoice_document', 'l10n_latam_base', diff --git a/l10n_uy_account/i18n/es.po b/l10n_uy_account/i18n/es.po index c91edfd9..0da08c8f 100644 --- a/l10n_uy_account/i18n/es.po +++ b/l10n_uy_account/i18n/es.po @@ -35,11 +35,6 @@ msgstr "Contado" msgid "Companies" msgstr "Compañías" -#. module: l10n_uy -#: model:ir.model.fields.selection,name:l10n_uy_account.selection__account_journal__l10n_uy_type__contingency -msgid "Contingency" -msgstr "Contingencia" - #. module: l10n_uy #: model:ir.model.fields,field_description:l10n_uy_account.field_res_company__l10n_uy_country_code msgid "Country Code" @@ -81,11 +76,6 @@ msgstr "" msgid "Document Types" msgstr "Tipos de Documentos" -#. module: l10n_uy -#: model:ir.model.fields.selection,name:l10n_uy_account.selection__account_journal__l10n_uy_type__electronic -msgid "Electronic" -msgstr "Electrónica" - #. module: l10n_uy #: model:ir.model,name:l10n_uy_account.model_l10n_latam_identification_type msgid "Identification Types" diff --git a/l10n_uy_account/i18n/l10n_uy_account.pot b/l10n_uy_account/i18n/l10n_uy_account.pot index de02faad..3c36c3f3 100644 --- a/l10n_uy_account/i18n/l10n_uy_account.pot +++ b/l10n_uy_account/i18n/l10n_uy_account.pot @@ -35,11 +35,6 @@ msgstr "" msgid "Companies" msgstr "" -#. module: l10n_uy -#: model:ir.model.fields.selection,name:l10n_uy_account.selection__account_journal__l10n_uy_type__contingency -msgid "Contingency" -msgstr "" - #. module: l10n_uy #: model:ir.model.fields,field_description:l10n_uy_account.field_res_company__l10n_uy_country_code msgid "Country Code" @@ -81,11 +76,6 @@ msgstr "" msgid "Document Types" msgstr "" -#. module: l10n_uy -#: model:ir.model.fields.selection,name:l10n_uy_account.selection__account_journal__l10n_uy_type__electronic -msgid "Electronic" -msgstr "" - #. module: l10n_uy #: model:ir.model,name:l10n_uy_account.model_l10n_latam_identification_type msgid "Identification Types" diff --git a/l10n_uy_account/models/account_journal.py b/l10n_uy_account/models/account_journal.py index be478c07..2033dac1 100644 --- a/l10n_uy_account/models/account_journal.py +++ b/l10n_uy_account/models/account_journal.py @@ -10,20 +10,14 @@ class AccountJournal(models.Model): _inherit = "account.journal" l10n_uy_type = fields.Selection( - [('manual', 'Manual'), - ('preprinted', 'Preprinted (Traditional)'), - ('electronic', 'Electronic'), - ('contingency', 'Contingency')], + [('manual', 'Manual / External Electronic Software'), + ('preprinted', 'Preprinted (Traditional)')], string='Invoicing Type', copy=False, default="manual", help="Type of journals that can be used for Uruguayan companies:\n" - "* Manual: You can generate any document type (electronic or traditional) entering the" + "* Manual / External Electronic Software: You can generate any document type (electronic or traditional) entering the" " document number manually. This is usefull if you have electronic documents created using" - " external systems and then you want to upload the documents to Odoo. Similar to Argentinean" - " Online Invoice type.\n" - "* Preprinted: For traditional invoicing using a pre printed tradicional documents (the ones with code 0).\n" - "* Electronic: To generate electronic documents via web service to DGI using UCFE Uruware provider service.\n" - "* Contingency: To generate documents to be send post morten via web service" - " (when electronic is not working).\n") + " external systems and then you want to upload the documents to Odoo. Similar to Argentinean Online Invoice type.\n" + "* Preprinted: For traditional invoicing using a pre printed tradicional documents (the ones with code 0).") l10n_uy_sequence_ids = fields.One2many('ir.sequence', 'l10n_latam_journal_id', string="Sequences (UY)") @@ -35,9 +29,9 @@ class AccountJournal(models.Model): @api.onchange('l10n_uy_type') def onchange_journal_uy_type(self): - """ If the uy type is contingency or preprintedthen use the unified sequence for all the documents """ + """ If the uy type is preprinted then use the unified sequence for all the documents """ self.l10n_uy_share_sequences = bool( - self.company_id.country_id.code == 'UY' and self.l10n_uy_type in ['preprinted', 'contingency']) + self.company_id.country_id.code == 'UY' and self.l10n_uy_type == 'preprinted') # TODO similar to _get_journal_codes() in l10n_ar, see if we can merge it in a future def _l10n_uy_get_journal_codes(self): @@ -46,12 +40,9 @@ def _l10n_uy_get_journal_codes(self): if self.type != 'sale': return [] + available_types = [] if self.l10n_uy_type == 'preprinted': available_types = ['0'] - elif self.l10n_uy_type == 'electronic': - available_types = ['101', '102', '103', '111', '112', '113', '121', '122', '123'] - elif self.l10n_uy_type == 'contingency': - available_types = ['201', '211', '212', '213', '221', '222', '223'] elif self.l10n_uy_type == 'manual': internal_types = ['invoice', 'debit_note', 'credit_note'] doc_types = self.env['l10n_latam.document.type'].search([ @@ -86,10 +77,9 @@ def _l10n_uy_create_document_sequences(self): self.ensure_one() if self.company_id.country_id.code != 'UY': return True - # Si no soy de tipo venta, no uso documentos o soy de tipo electronico/manual no genero secuencias. - # * en diarios electronicos la secuencias se asignan al validar la factura durecto desde Uruware. + # Si no soy de tipo venta, no uso documentos o soy de tipo manual no genero secuencias. # * en diarios manuales los usuarios no tienen secuencia y deben agregar el numero de documento de manera manual siempre - if not self.type == 'sale' or not self.l10n_latam_use_documents or self.l10n_uy_type in ['electronic', 'manual']: + if not self.type == 'sale' or not self.l10n_latam_use_documents or self.l10n_uy_type == 'manual': return False sequences = self.l10n_uy_sequence_ids diff --git a/l10n_uy_account/models/account_move.py b/l10n_uy_account/models/account_move.py index 3ba8ff8c..0662d2cc 100644 --- a/l10n_uy_account/models/account_move.py +++ b/l10n_uy_account/models/account_move.py @@ -56,14 +56,6 @@ def _get_document_type_sequence(self): """ Return the match sequences for the given journal and invoice """ self.ensure_one() if self.journal_id.l10n_latam_use_documents and self.l10n_latam_country_code == 'UY': - - # This is needed only in version 13.0, need to remove in version 15.0 - # We need this in order to avoid Odoo ask the user the document number for the electronic documents - # We use the sequence auto generated from Odoo when the journals is created as a dummy sequence - # actually the document number is set when invoice is validated getting the info from UCFE Uruware - if self.journal_id.l10n_uy_type == 'electronic': - return self.journal_id.sequence_id - if self.journal_id.l10n_uy_share_sequences: return self.journal_id.l10n_uy_sequence_ids res = self.journal_id.l10n_uy_sequence_ids.filtered( diff --git a/l10n_uy_edi/__manifest__.py b/l10n_uy_edi/__manifest__.py index beb70df5..d1f2d1b4 100644 --- a/l10n_uy_edi/__manifest__.py +++ b/l10n_uy_edi/__manifest__.py @@ -7,7 +7,7 @@ 'author': 'ADHOC SA', 'category': 'Localization', 'license': 'LGPL-3', - 'version': '13.0.1.8.0', + 'version': '13.0.1.9.0', 'depends': [ 'l10n_uy_account', 'account_debit_note', diff --git a/l10n_uy_edi/i18n/es.po b/l10n_uy_edi/i18n/es.po index 8f3c9c53..02f04432 100644 --- a/l10n_uy_edi/i18n/es.po +++ b/l10n_uy_edi/i18n/es.po @@ -392,6 +392,11 @@ msgstr "Consultar Notificaciones UCFE" msgid "Contact" msgstr "Contacto" +#. module: l10n_uy +#: model:ir.model.fields.selection,name:l10n_uy_account.selection__account_journal__l10n_uy_type__contingency +msgid "Contingency" +msgstr "Contingencia" + #. module: l10n_uy_edi #: model:ir.model.fields,help:l10n_uy_edi.field_res.partner.update.from.padron.uy.wizard__title_case msgid "Converts retreived text fields to Title Case." @@ -505,6 +510,11 @@ msgstr "" "E-ticket necesita estos valores porque el monto total > 10.000 * Unidad " "Indexada Uruguaya" +#. module: l10n_uy +#: model:ir.model.fields.selection,name:l10n_uy_account.selection__account_journal__l10n_uy_type__electronic +msgid "Electronic" +msgstr "Electrónica" + #. module: l10n_uy_edi #: model:ir.model.fields.selection,name:l10n_uy_edi.selection__account_move__l10n_uy_cfe_state__rejected msgid "ERROR: CFE Rejected by DGI" diff --git a/l10n_uy_edi/models/account_journal.py b/l10n_uy_edi/models/account_journal.py index b5552195..e6b0515f 100644 --- a/l10n_uy_edi/models/account_journal.py +++ b/l10n_uy_edi/models/account_journal.py @@ -6,9 +6,37 @@ class AccountJournal(models.Model): _inherit = 'account.journal' + l10n_uy_type = fields.Selection( + selection_add=[ + ('electronic', 'Electronic'), + ('contingency', 'Contingency')], + help="Type of journals that can be used for Uruguayan companies:\n" + "* Manual / External Electronic Software: You can generate any document type (electronic or traditional) entering the" + " document number manually. This is usefull if you have electronic documents created using" + " external systems and then you want to upload the documents to Odoo. Similar to Argentinean Online Invoice type.\n" + "* Preprinted: For traditional invoicing using a pre printed tradicional documents (the ones with code 0).\n" + "* Electronic: To generate electronic documents via web service to DGI using Odoo integration wittb UCFE Uruware provider service.\n" + "* Contingency: To generate documents to be send post morten via web service (when electronic is not working).\n") + # TODO Tenemos algo que se llama puntos de emision, ver si esto lo podemos configurar aca, # seria como el AFIP Pos Number? + # TODO similar to _get_journal_codes() in l10n_ar, see if we can merge it in a future + def _l10n_uy_get_journal_codes(self): + """ return list of the available document type codes for uruguayan sales journals, add the available electronic documents. + This is used as the doc types shown in the invoice when selecting a journal type """ + available_types = super()._l10n_uy_get_journal_codes() + self.ensure_one() + if self.type != 'sale': + return [] + + if self.l10n_uy_type == 'electronic': + available_types = ['101', '102', '103', '111', '112', '113', '121', '122', '123'] + elif self.l10n_uy_type == 'contingency': + available_types = ['201', '211', '212', '213', '221', '222', '223'] + + return available_types + def _update_journal_document_types(self): self.ensure_one() if self.company_id.country_id.code != 'UY': @@ -39,22 +67,28 @@ def onchange_journal_uy_type(self): if self.company_id.country_id.code == 'UY' and self.l10n_latam_use_documents: self.l10n_uy_share_sequences = True - # def _l10n_uy_create_document_sequences(self): - # """ IF DGI Configuration change try to review if this can be done and then create / update the document - # sequences """ - # """ After creating the document sequences we try to sync document next numbers with the last numbers in Uruware - # """ - # # TODO KZ WIP I think this should be done before - # if self.type == 'sale' and self.l10n_uy_type == 'electronic': - # try: - # self.l10n_ar_sync_next_number_with_afip() - # # TODO implementar get Sequence numbers - # # 4.3 Solicitud de rango de numeración. consulta 220 - # # 4.13 Consulta de CAE Este consulta 230 - # # 4.16 Solicitar anulación de un número de CFE no utilizado. consulta 380 - # - # except Exception as error: - # _logger.info(_('Could not synchronize next number with the Uruware last numbers %s'), repr(error)) - # else: - # res = super()._l10n_ar_create_document_sequences() - # return res + # TODO KZ simil to _l10n_ar_create_document_sequences, since to merge this two methods in the future + def _l10n_uy_create_document_sequences(self): + """ Si soy de tipo electronico no genero secuencias: esto porque en diarios electronicos la secuencias se + # asignan al validar la factura durecto desde Uruware """ + self.ensure_one() + if self.company_id.country_id.code == 'UY' and self.l10n_uy_type == 'electronic': + return False + return super()._l10n_uy_create_document_sequences() + + # TODO En el caso de querer sincronizar la informacion del ultimo y proximo numero de documento como lo tenemos en 13 Aargentina + # o capaz algo con diario de contigencia usar algo similar a""" + + # if self.type == 'sale' and self.l10n_uy_type == 'electronic': + # try: + # self.l10n_ar_sync_next_number_with_afip() + # # TODO implementar get Sequence numbers + # # 4.3 Solicitud de rango de numeración. consulta 220 + # # 4.13 Consulta de CAE Este consulta 230 + # # 4.16 Solicitar anulación de un número de CFE no utilizado. consulta 380 + # + # except Exception as error: + # _logger.info(_('Could not synchronize next number with the Uruware last numbers %s'), repr(error)) + # else: + # res = super()._l10n_ar_create_document_sequences() + # return res diff --git a/l10n_uy_edi/models/account_move.py b/l10n_uy_edi/models/account_move.py index 074b6f6b..98bc14b7 100644 --- a/l10n_uy_edi/models/account_move.py +++ b/l10n_uy_edi/models/account_move.py @@ -233,6 +233,15 @@ def _is_dummy_dgi_validation(self): return self.company_id._uy_get_environment_type() == 'testing' and \ not self.company_id.sudo()._is_connection_info_complete(raise_exception=False) + def _get_document_type_sequence(self): + """ We need this in order to avoid Odoo ask the user the document number for the electronic documents + The hack is that we use the sequence auto generated from Odoo when the journals is created as a dummy sequence + actually the document number is set when invoice is validated getting the info from UCFE Uruware """ + # NOTE: This is needed only in version 13.0, need to remove in version 15.0 + self.ensure_one() + if self.journal_id.l10n_uy_type == 'electronic': + return self.journal_id.sequence_id + return super()._get_document_type_sequence() def action_l10n_uy_get_uruware_inv(self): """ 360: Consulta de estado de CFE: estado del comprobante en DGI,