Commit c7d0d550 authored by Daniel Santibáñez Polanco's avatar Daniel Santibáñez Polanco
Browse files

Cambios acumulados

parent eeacc378
......@@ -2,7 +2,7 @@
{
"name": """Factura de Exportación Electrónica para Chile\
""",
'version': '0.18.6',
'version': '0.18.7',
'category': 'Localization/Chile',
'sequence': 12,
'author': 'Daniel Santibáñez Polanco, Cooperativa OdooCoop',
......
# -*- coding: utf-8 -*-
from odoo import fields, models, api, _
from odoo.exceptions import UserError
from datetime import datetime
import logging
_logger = logging.getLogger(__name__)
try:
from suds.client import Client
except:
pass
server_url = {'SIICERT': 'https://maullin.sii.cl/DTEWS/','SII':'https://palena.sii.cl/DTEWS/'}
class Exportacion(models.Model):
......@@ -393,6 +400,44 @@ class Exportacion(models.Model):
})
seguro.valor = self.monto_seguro
def _get_dte_status(self):
for r in self:
if r.sii_xml_request.state not in ['Aceptado', 'Rechazado']:
continue
rut_emisor = r.company_id.partner_id.rut()
token = r.sii_xml_request.get_token(self.env.user, r.company_id)
url = server_url[r.company_id.dte_service_provider] + 'QueryEstDte.jws?WSDL'
_server = Client(url)
commercial_partner_id = r.commercial_partner_id or r.partner_id
receptor = commercial_partner_id.rut()
if r._es_exportacion():
receptor = '55555555-5'
date_invoice = datetime.strptime(r.date_invoice, "%Y-%m-%d").strftime("%d-%m-%Y")
signature_id = self.env.user.get_digital_signature(r.company_id)
rut = signature_id.subject_serial_number
try:
respuesta = _server.service.getEstDte(
rut[:-2],
str(rut[-1]),
rut_emisor[:-2],
rut_emisor[-1],
receptor[:-2],
receptor[-1],
str(r.document_class_id.sii_code),
str(r.sii_document_number),
date_invoice,
str(int(r.amount_total)),
token,
)
r.sii_message = respuesta
r.get_sii_result()
except Exception as e:
msg = "Error al obtener Estado DTE"
_logger.warning("%s: %s" % (msg, str(e)))
if e.args[0][0] == 503:
raise UserError('%s: Conexión al SII caída/rechazada o el SII está temporalmente fuera de línea, reintente la acción' % (msg))
raise UserError(("%s: %s" % (msg, str(e))))
@api.onchange('bultos')
def tot_bultos(self):
tot_bultos = 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment