1
1
import re
2
+ import logging
3
+
2
4
3
5
from odoo import _ , api , models
4
6
5
7
from odoo .exceptions import UserError
6
8
from odoo .tools import safe_eval
7
9
10
+ _logger = logging .getLogger (__name__ )
11
+
8
12
9
13
class L10nUyEdiDocument (models .Model ):
10
14
@@ -14,8 +18,10 @@ class L10nUyEdiDocument(models.Model):
14
18
15
19
def _get_ws_url (self , ws_endpoint , company ):
16
20
# EXTEND l10n_uy_edi
17
- """ Si utiliza uruware por contrato externo. modificar para soportar las dos url,
18
- una de testing y una de prod, asi no tiene que configurar el dato cada vez """
21
+ """ Si utiliza uruware por Contrato Externo (no el de Odoo) da la posibilidad
22
+ de utilizar dos urls en system parametros, uno para test y otro para pod
23
+
24
+ Asi no tiene que configurar el dato cada vez que lo vayan a usar """
19
25
url = super ()._get_ws_url (ws_endpoint , company )
20
26
21
27
if company .l10n_uy_edi_ucfe_env == "demo" :
@@ -27,26 +33,29 @@ def _get_ws_url(self, ws_endpoint, company):
27
33
query_param = self .env ["ir.config_parameter" ].sudo ().get_param (
28
34
"l10n_uy_edi.l10n_uy_edi_ucfe_query_url" + company .l10n_uy_edi_ucfe_env )
29
35
36
+ pattern = {
37
+ "inbox" : "https://.*.ucfe.com.uy/inbox.*/cfeservice.svc" ,
38
+ "query" : "https://.*.ucfe.com.uy/query.*/webservicesfe.svc" ,
39
+ }
30
40
if ws_endpoint == "inbox" and inbox_param :
31
41
url = inbox_param
32
- pattern = "https://.*.ucfe.com.uy/inbox.*/cfeservice.svc"
33
42
elif ws_endpoint == "query" and query_param :
34
43
url = query_param
35
- pattern = "https://.*.ucfe.com.uy/query.*/webservicesfe.svc"
44
+ else :
45
+ _logger .info ("Using Odoo defaults values" )
36
46
37
- print (" ----- url %s" % url )
38
- return url if re .match (pattern , url , re .IGNORECASE ) is not None else False
47
+ return url if re .match (pattern [ws_endpoint ], url , re .IGNORECASE ) is not None else False
39
48
40
49
def action_update_dgi_state (self ):
41
50
# EXTEND l10n_uy_edi
42
51
""" Permitimos actualizar estado solo si tenemos UUID y solo si esta en esperando respuesta.
43
- si hay error no hay nada que consultar, y si fue aceptado rechazado ya no necesita ser actualizado """
44
- for move in self :
45
- if not move . l10n_uy_edi_cfe_uuid :
52
+ Si hay error no hay nada que consultar, y si fue aceptado rechazado ya no necesita ser actualizado """
53
+ for doc in self :
54
+ if not doc . uuid :
46
55
raise UserError (_ ("Please return a 'UUID CFE Key' in order to continue" ))
47
- if move . l10n_uy_edi_cfe_state == "error" :
56
+ if doc . state == "error" :
48
57
raise UserError (_ ("You can not obtain the invoice with errors" ))
49
- if move . l10n_uy_edi_cfe_state != "received" :
58
+ if doc . state != "received" :
50
59
raise UserError (_ ("You can not update the state of a accepted/rejected invoice" ))
51
60
52
61
super ().action_update_dgi_state ()
0 commit comments