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

[IMP]Unificación RUT

parent 03abc5de
......@@ -2,7 +2,7 @@
{
"name": """Factura de Exportación Electrónica para Chile\
""",
'version': '0.18.5',
'version': '0.18.6',
'category': 'Localization/Chile',
'sequence': 12,
'author': 'Daniel Santibáñez Polanco, Cooperativa OdooCoop',
......
......@@ -419,7 +419,7 @@
<field name="code">232</field>
</record>
<record model="aduanas.paises">
<record model="aduanas.paises" id="gr">
<field name="name">GRECIA</field>
<field name="code">520</field>
......@@ -480,19 +480,15 @@
</record>
<record model="aduanas.paises">
<field name="name">HOLANDA</field>
<field name="code">515</field>
</record>
<record model="aduanas.paises">
<record model="aduanas.paises" id="hk">
<field name="name">HONG KONG - REGIÓN ADMINISTRATIVA ESPECIAL DE CHINA</field>
<field name="code">342</field>
<field name="abreviatura">HONG KONG</field>
</record>
<record model="aduanas.paises">
<record model="aduanas.paises" id="hn">
<field name="name">HONDURAS</field>
<field name="code">214</field>
......
id,aduanas_id/id
base.ad,ad
base.af,af
base.ag,ag
base.ai,ai
base.al,al
base.am,am
base.ad,ad
base.ao,ao
base.ai,ai
base.ag,ag
base.ar,ar
base.au,au
base.at,at
base.au,au
base.be,be
base.bo,bo
base.br,br
......@@ -18,24 +18,27 @@ base.cn,cn
base.co,co
base.cu,cu
base.es,es
base.us,us
base.fr,fr
base.gr,gr
base.hk,hk
base.hn,hn
base.in,in
base.it,it
base.jm,jm
base.jp,jp
base.my,my
base.mx,mx
base.mn,mn
base.ms,ms
base.ni,ni
base.mx,mx
base.my,my
base.ne,ne
base.ng,ng
base.ni,ni
base.pe,pe
base.pl,pl
base.pt,pt
base.pr,pr
base.uk,uk
base.pt,pt
base.ru,ru
base.uk,uk
base.us,us
base.uy,uy
base.ve,ve
......@@ -110,12 +110,6 @@ class Exportacion(models.Model):
default.setdefault('exportacion', exp.id)
return super(Exportacion, self).copy(default)
def format_vat(self, value, con_cero=False):
if self[0]._es_exportacion():
if self[0].company_id.vat != value:
value = "CL555555555"
return super(Exportacion, self).format_vat(value, con_cero)
@api.multi
def crear_exportacion(self):
self.exportacion = self.env['account.invoice.exportacion'].create({
......@@ -192,37 +186,40 @@ class Exportacion(models.Model):
def _receptor(self):
Receptor = {}
if not self.commercial_partner_id.vat and not self._es_boleta() and not self._nc_boleta() and not self._es_exportacion():
commercial_partner_id = self.commercial_partner_id or self.partner_id.commercial_partner_id
if not commercial_partner_id.vat and not self._es_boleta() and not self._nc_boleta() and not self._es_exportacion():
raise UserError("Debe Ingresar RUT Receptor")
#if self._es_boleta():
# Receptor['CdgIntRecep']
Receptor['RUTRecep'] = self.format_vat(self.commercial_partner_id.vat)
Receptor['RznSocRecep'] = self._acortar_str( self.commercial_partner_id.name, 100)
if not self.partner_id or Receptor['RUTRecep'] == '66666666-6':
Receptor['RUTRecep'] = commercial_partner_id.rut()
Receptor['RznSocRecep'] = self._acortar_str( commercial_partner_id.name, 100)
if not self.partner_id or (not self._es_exportacion() and Receptor['RUTRecep'] == '66666666-6'):
return Receptor
elif self._es_exportacion():
Receptor['RUTRecep'] = '55.555.555-5'
if not self._es_boleta() and not self._nc_boleta():
GiroRecep = self.acteco_id.name or self.commercial_partner_id.activity_description.name
GiroRecep = self.acteco_id.name or commercial_partner_id.activity_description.name
if not GiroRecep and not self._es_exportacion():
raise UserError(_('Seleccione giro del partner'))
if GiroRecep:
Receptor['GiroRecep'] = self._acortar_str(GiroRecep, 40)
if self.partner_id.phone or self.commercial_partner_id.phone:
Receptor['Contacto'] = self._acortar_str(self.partner_id.phone or self.commercial_partner_id.phone or self.partner_id.email, 80)
if (self.commercial_partner_id.email or self.commercial_partner_id.dte_email or self.partner_id.email or self.partner_id.dte_email) and not self._es_boleta():
Receptor['CorreoRecep'] = self.commercial_partner_id.dte_email or self.partner_id.dte_email or self.commercial_partner_id.email or self.partner_id.email
street_recep = (self.partner_id.street or self.commercial_partner_id.street or False)
if self.partner_id.phone or commercial_partner_id.phone:
Receptor['Contacto'] = self._acortar_str(self.partner_id.phone or commercial_partner_id.phone or self.partner_id.email, 80)
if (commercial_partner_id.email or commercial_partner_id.dte_email or self.partner_id.email or self.partner_id.dte_email) and not self._es_boleta():
Receptor['CorreoRecep'] = commercial_partner_id.dte_email or self.partner_id.dte_email or commercial_partner_id.email or self.partner_id.email
street_recep = (self.partner_id.street or commercial_partner_id.street or False)
if not street_recep and not self._es_boleta() and not self._nc_boleta():
# or self.indicador_servicio in [1, 2]:
raise UserError('Debe Ingresar dirección del cliente')
street2_recep = (self.partner_id.street2 or self.commercial_partner_id.street2 or False)
street2_recep = (self.partner_id.street2 or commercial_partner_id.street2 or False)
if street_recep or street2_recep:
Receptor['DirRecep'] = self._acortar_str(street_recep + (' ' + street2_recep if street2_recep else ''), 70)
cmna_recep = self.partner_id.city_id.name or self.commercial_partner_id.city_id.name
cmna_recep = self.partner_id.city_id.name or commercial_partner_id.city_id.name
if not cmna_recep and not self._es_boleta() and not self._nc_boleta() and not self._es_exportacion():
raise UserError('Debe Ingresar Comuna del cliente')
else:
Receptor['CmnaRecep'] = cmna_recep
ciudad_recep = self.partner_id.city or self.commercial_partner_id.city
ciudad_recep = self.partner_id.city or commercial_partner_id.city
if ciudad_recep:
Receptor['CiudadRecep'] = ciudad_recep
Receptor['Nacionalidad'] = self.partner_id.commercial_partner_id.country_id.aduanas_id.code
......@@ -272,7 +269,7 @@ class Exportacion(models.Model):
if expo.chofer_id:
Aduana['NombreTransp'] = expo.chofer_id.name
if expo.carrier_id:
Aduana['RUTCiaTransp'] = self.format_vat(expo.carrier_id.partner_id.vat)
Aduana['RUTCiaTransp'] = expo.carrier_id.partner_id.rut()
if expo.carrier_id:
Aduana['NomCiaTransp'] = expo.carrier_id.name
#Aduana['IdAdicTransp'] = self.indicador_adicional
......@@ -326,14 +323,14 @@ class Exportacion(models.Model):
if not self.chofer.vat:
raise UserError("Debe llenar los datos del chofer")
if self.transport_type == 2:
Transporte['RUTTrans'] = self.format_vat(self.company_id.vat)
Transporte['RUTTrans'] = self.company_id.partner_id.rut()
else:
if not self.carrier_id.partner_id.vat:
raise UserError("Debe especificar el RUT del transportista, en su ficha de partner")
Transporte['RUTTrans'] = self.format_vat(self.carrier_id.partner_id.vat)
Transporte['RUTTrans'] = self.carrier_id.partner_id.rut()
if self.chofer:
Transporte['Chofer'] = {}
Transporte['Chofer']['RUTChofer'] = self.format_vat(self.chofer.vat)
Transporte['Chofer']['RUTChofer'] = self.chofer.rut()
Transporte['Chofer']['NombreChofer'] = self.chofer.name[:30]
if not self._es_exportacion():
partner_id = self.partner_id or self.company_id.partner_id
......
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