Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] l10n_uy_account, l10n_uy_edi: journals type #38

Open
wants to merge 1 commit into
base: 13.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion l10n_uy_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 0 additions & 10 deletions l10n_uy_account/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 0 additions & 10 deletions l10n_uy_account/i18n/l10n_uy_account.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
30 changes: 10 additions & 20 deletions l10n_uy_account/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand All @@ -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):
Expand All @@ -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([
Expand Down Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions l10n_uy_account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion l10n_uy_edi/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 10 additions & 0 deletions l10n_uy_edi/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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"
Expand Down
72 changes: 53 additions & 19 deletions l10n_uy_edi/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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
9 changes: 9 additions & 0 deletions l10n_uy_edi/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down