Skip to content

Commit f1d39fb

Browse files
committed
[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).
1 parent ded2de6 commit f1d39fb

File tree

9 files changed

+84
-69
lines changed

9 files changed

+84
-69
lines changed

l10n_uy_account/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
'author': 'ADHOC SA',
88
'category': 'Localization',
99
'license': 'LGPL-3',
10-
'version': '13.0.1.6.0',
10+
'version': '13.0.1.7.0',
1111
'depends': [
1212
'l10n_latam_invoice_document',
1313
'l10n_latam_base',

l10n_uy_account/i18n/es.po

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ msgstr "Contado"
3535
msgid "Companies"
3636
msgstr "Compañías"
3737

38-
#. module: l10n_uy
39-
#: model:ir.model.fields.selection,name:l10n_uy_account.selection__account_journal__l10n_uy_type__contingency
40-
msgid "Contingency"
41-
msgstr "Contingencia"
42-
4338
#. module: l10n_uy
4439
#: model:ir.model.fields,field_description:l10n_uy_account.field_res_company__l10n_uy_country_code
4540
msgid "Country Code"
@@ -81,11 +76,6 @@ msgstr ""
8176
msgid "Document Types"
8277
msgstr "Tipos de Documentos"
8378

84-
#. module: l10n_uy
85-
#: model:ir.model.fields.selection,name:l10n_uy_account.selection__account_journal__l10n_uy_type__electronic
86-
msgid "Electronic"
87-
msgstr "Electrónica"
88-
8979
#. module: l10n_uy
9080
#: model:ir.model,name:l10n_uy_account.model_l10n_latam_identification_type
9181
msgid "Identification Types"

l10n_uy_account/i18n/l10n_uy_account.pot

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ msgstr ""
3535
msgid "Companies"
3636
msgstr ""
3737

38-
#. module: l10n_uy
39-
#: model:ir.model.fields.selection,name:l10n_uy_account.selection__account_journal__l10n_uy_type__contingency
40-
msgid "Contingency"
41-
msgstr ""
42-
4338
#. module: l10n_uy
4439
#: model:ir.model.fields,field_description:l10n_uy_account.field_res_company__l10n_uy_country_code
4540
msgid "Country Code"
@@ -81,11 +76,6 @@ msgstr ""
8176
msgid "Document Types"
8277
msgstr ""
8378

84-
#. module: l10n_uy
85-
#: model:ir.model.fields.selection,name:l10n_uy_account.selection__account_journal__l10n_uy_type__electronic
86-
msgid "Electronic"
87-
msgstr ""
88-
8979
#. module: l10n_uy
9080
#: model:ir.model,name:l10n_uy_account.model_l10n_latam_identification_type
9181
msgid "Identification Types"

l10n_uy_account/models/account_journal.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,14 @@ class AccountJournal(models.Model):
1010
_inherit = "account.journal"
1111

1212
l10n_uy_type = fields.Selection(
13-
[('manual', 'Manual'),
14-
('preprinted', 'Preprinted (Traditional)'),
15-
('electronic', 'Electronic'),
16-
('contingency', 'Contingency')],
13+
[('manual', 'Manual / External Electronic Software'),
14+
('preprinted', 'Preprinted (Traditional)')],
1715
string='Invoicing Type', copy=False, default="manual",
1816
help="Type of journals that can be used for Uruguayan companies:\n"
19-
"* Manual: You can generate any document type (electronic or traditional) entering the"
17+
"* Manual / External Electronic Software: You can generate any document type (electronic or traditional) entering the"
2018
" document number manually. This is usefull if you have electronic documents created using"
21-
" external systems and then you want to upload the documents to Odoo. Similar to Argentinean"
22-
" Online Invoice type.\n"
23-
"* Preprinted: For traditional invoicing using a pre printed tradicional documents (the ones with code 0).\n"
24-
"* Electronic: To generate electronic documents via web service to DGI using UCFE Uruware provider service.\n"
25-
"* Contingency: To generate documents to be send post morten via web service"
26-
" (when electronic is not working).\n")
19+
" external systems and then you want to upload the documents to Odoo. Similar to Argentinean Online Invoice type.\n"
20+
"* Preprinted: For traditional invoicing using a pre printed tradicional documents (the ones with code 0).")
2721

2822

2923
l10n_uy_sequence_ids = fields.One2many('ir.sequence', 'l10n_latam_journal_id', string="Sequences (UY)")
@@ -35,9 +29,9 @@ class AccountJournal(models.Model):
3529

3630
@api.onchange('l10n_uy_type')
3731
def onchange_journal_uy_type(self):
38-
""" If the uy type is contingency or preprintedthen use the unified sequence for all the documents """
32+
""" If the uy type is preprinted then use the unified sequence for all the documents """
3933
self.l10n_uy_share_sequences = bool(
40-
self.company_id.country_id.code == 'UY' and self.l10n_uy_type in ['preprinted', 'contingency'])
34+
self.company_id.country_id.code == 'UY' and self.l10n_uy_type == 'preprinted')
4135

4236
# TODO similar to _get_journal_codes() in l10n_ar, see if we can merge it in a future
4337
def _l10n_uy_get_journal_codes(self):
@@ -46,12 +40,9 @@ def _l10n_uy_get_journal_codes(self):
4640
if self.type != 'sale':
4741
return []
4842

43+
available_types = []
4944
if self.l10n_uy_type == 'preprinted':
5045
available_types = ['0']
51-
elif self.l10n_uy_type == 'electronic':
52-
available_types = ['101', '102', '103', '111', '112', '113', '121', '122', '123']
53-
elif self.l10n_uy_type == 'contingency':
54-
available_types = ['201', '211', '212', '213', '221', '222', '223']
5546
elif self.l10n_uy_type == 'manual':
5647
internal_types = ['invoice', 'debit_note', 'credit_note']
5748
doc_types = self.env['l10n_latam.document.type'].search([
@@ -86,10 +77,9 @@ def _l10n_uy_create_document_sequences(self):
8677
self.ensure_one()
8778
if self.company_id.country_id.code != 'UY':
8879
return True
89-
# Si no soy de tipo venta, no uso documentos o soy de tipo electronico/manual no genero secuencias.
90-
# * en diarios electronicos la secuencias se asignan al validar la factura durecto desde Uruware.
80+
# Si no soy de tipo venta, no uso documentos o soy de tipo manual no genero secuencias.
9181
# * en diarios manuales los usuarios no tienen secuencia y deben agregar el numero de documento de manera manual siempre
92-
if not self.type == 'sale' or not self.l10n_latam_use_documents or self.l10n_uy_type in ['electronic', 'manual']:
82+
if not self.type == 'sale' or not self.l10n_latam_use_documents or self.l10n_uy_type == 'manual':
9383
return False
9484

9585
sequences = self.l10n_uy_sequence_ids

l10n_uy_account/models/account_move.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,6 @@ def _get_document_type_sequence(self):
5656
""" Return the match sequences for the given journal and invoice """
5757
self.ensure_one()
5858
if self.journal_id.l10n_latam_use_documents and self.l10n_latam_country_code == 'UY':
59-
60-
# This is needed only in version 13.0, need to remove in version 15.0
61-
# We need this in order to avoid Odoo ask the user the document number for the electronic documents
62-
# We use the sequence auto generated from Odoo when the journals is created as a dummy sequence
63-
# actually the document number is set when invoice is validated getting the info from UCFE Uruware
64-
if self.journal_id.l10n_uy_type == 'electronic':
65-
return self.journal_id.sequence_id
66-
6759
if self.journal_id.l10n_uy_share_sequences:
6860
return self.journal_id.l10n_uy_sequence_ids
6961
res = self.journal_id.l10n_uy_sequence_ids.filtered(

l10n_uy_edi/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
'author': 'ADHOC SA',
88
'category': 'Localization',
99
'license': 'LGPL-3',
10-
'version': '13.0.1.8.0',
10+
'version': '13.0.1.9.0',
1111
'depends': [
1212
'l10n_uy_account',
1313
'account_debit_note',

l10n_uy_edi/i18n/es.po

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,11 @@ msgstr "Consultar Notificaciones UCFE"
392392
msgid "Contact"
393393
msgstr "Contacto"
394394

395+
#. module: l10n_uy
396+
#: model:ir.model.fields.selection,name:l10n_uy_account.selection__account_journal__l10n_uy_type__contingency
397+
msgid "Contingency"
398+
msgstr "Contingencia"
399+
395400
#. module: l10n_uy_edi
396401
#: model:ir.model.fields,help:l10n_uy_edi.field_res.partner.update.from.padron.uy.wizard__title_case
397402
msgid "Converts retreived text fields to Title Case."
@@ -505,6 +510,11 @@ msgstr ""
505510
"E-ticket necesita estos valores porque el monto total > 10.000 * Unidad "
506511
"Indexada Uruguaya"
507512

513+
#. module: l10n_uy
514+
#: model:ir.model.fields.selection,name:l10n_uy_account.selection__account_journal__l10n_uy_type__electronic
515+
msgid "Electronic"
516+
msgstr "Electrónica"
517+
508518
#. module: l10n_uy_edi
509519
#: model:ir.model.fields.selection,name:l10n_uy_edi.selection__account_move__l10n_uy_cfe_state__rejected
510520
msgid "ERROR: CFE Rejected by DGI"

l10n_uy_edi/models/account_journal.py

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,37 @@ class AccountJournal(models.Model):
66

77
_inherit = 'account.journal'
88

9+
l10n_uy_type = fields.Selection(
10+
selection_add=[
11+
('electronic', 'Electronic'),
12+
('contingency', 'Contingency')],
13+
help="Type of journals that can be used for Uruguayan companies:\n"
14+
"* Manual / External Electronic Software: You can generate any document type (electronic or traditional) entering the"
15+
" document number manually. This is usefull if you have electronic documents created using"
16+
" external systems and then you want to upload the documents to Odoo. Similar to Argentinean Online Invoice type.\n"
17+
"* Preprinted: For traditional invoicing using a pre printed tradicional documents (the ones with code 0).\n"
18+
"* Electronic: To generate electronic documents via web service to DGI using Odoo integration wittb UCFE Uruware provider service.\n"
19+
"* Contingency: To generate documents to be send post morten via web service (when electronic is not working).\n")
20+
921
# TODO Tenemos algo que se llama puntos de emision, ver si esto lo podemos configurar aca,
1022
# seria como el AFIP Pos Number?
1123

24+
# TODO similar to _get_journal_codes() in l10n_ar, see if we can merge it in a future
25+
def _l10n_uy_get_journal_codes(self):
26+
""" return list of the available document type codes for uruguayan sales journals, add the available electronic documents.
27+
This is used as the doc types shown in the invoice when selecting a journal type """
28+
available_types = super()._l10n_uy_get_journal_codes()
29+
self.ensure_one()
30+
if self.type != 'sale':
31+
return []
32+
33+
if self.l10n_uy_type == 'electronic':
34+
available_types = ['101', '102', '103', '111', '112', '113', '121', '122', '123']
35+
elif self.l10n_uy_type == 'contingency':
36+
available_types = ['201', '211', '212', '213', '221', '222', '223']
37+
38+
return available_types
39+
1240
def _update_journal_document_types(self):
1341
self.ensure_one()
1442
if self.company_id.country_id.code != 'UY':
@@ -39,22 +67,28 @@ def onchange_journal_uy_type(self):
3967
if self.company_id.country_id.code == 'UY' and self.l10n_latam_use_documents:
4068
self.l10n_uy_share_sequences = True
4169

42-
# def _l10n_uy_create_document_sequences(self):
43-
# """ IF DGI Configuration change try to review if this can be done and then create / update the document
44-
# sequences """
45-
# """ After creating the document sequences we try to sync document next numbers with the last numbers in Uruware
46-
# """
47-
# # TODO KZ WIP I think this should be done before
48-
# if self.type == 'sale' and self.l10n_uy_type == 'electronic':
49-
# try:
50-
# self.l10n_ar_sync_next_number_with_afip()
51-
# # TODO implementar get Sequence numbers
52-
# # 4.3 Solicitud de rango de numeración. consulta 220
53-
# # 4.13 Consulta de CAE Este consulta 230
54-
# # 4.16 Solicitar anulación de un número de CFE no utilizado. consulta 380
55-
#
56-
# except Exception as error:
57-
# _logger.info(_('Could not synchronize next number with the Uruware last numbers %s'), repr(error))
58-
# else:
59-
# res = super()._l10n_ar_create_document_sequences()
60-
# return res
70+
# TODO KZ simil to _l10n_ar_create_document_sequences, since to merge this two methods in the future
71+
def _l10n_uy_create_document_sequences(self):
72+
""" Si soy de tipo electronico no genero secuencias: esto porque en diarios electronicos la secuencias se
73+
# asignan al validar la factura durecto desde Uruware """
74+
self.ensure_one()
75+
if self.company_id.country_id.code == 'UY' and self.l10n_uy_type == 'electronic':
76+
return False
77+
return super()._l10n_uy_create_document_sequences()
78+
79+
# TODO En el caso de querer sincronizar la informacion del ultimo y proximo numero de documento como lo tenemos en 13 Aargentina
80+
# o capaz algo con diario de contigencia usar algo similar a"""
81+
82+
# if self.type == 'sale' and self.l10n_uy_type == 'electronic':
83+
# try:
84+
# self.l10n_ar_sync_next_number_with_afip()
85+
# # TODO implementar get Sequence numbers
86+
# # 4.3 Solicitud de rango de numeración. consulta 220
87+
# # 4.13 Consulta de CAE Este consulta 230
88+
# # 4.16 Solicitar anulación de un número de CFE no utilizado. consulta 380
89+
#
90+
# except Exception as error:
91+
# _logger.info(_('Could not synchronize next number with the Uruware last numbers %s'), repr(error))
92+
# else:
93+
# res = super()._l10n_ar_create_document_sequences()
94+
# return res

l10n_uy_edi/models/account_move.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,15 @@ def _is_dummy_dgi_validation(self):
233233
return self.company_id._uy_get_environment_type() == 'testing' and \
234234
not self.company_id.sudo()._is_connection_info_complete(raise_exception=False)
235235

236+
def _get_document_type_sequence(self):
237+
""" We need this in order to avoid Odoo ask the user the document number for the electronic documents
238+
The hack is that we use the sequence auto generated from Odoo when the journals is created as a dummy sequence
239+
actually the document number is set when invoice is validated getting the info from UCFE Uruware """
240+
# NOTE: This is needed only in version 13.0, need to remove in version 15.0
241+
self.ensure_one()
242+
if self.journal_id.l10n_uy_type == 'electronic':
243+
return self.journal_id.sequence_id
244+
return super()._get_document_type_sequence()
236245

237246
def action_l10n_uy_get_uruware_inv(self):
238247
""" 360: Consulta de estado de CFE: estado del comprobante en DGI,

0 commit comments

Comments
 (0)