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

[WIP]Creación de Exportación

parent 5349ee1f
......@@ -49,69 +49,96 @@ class Exportacion(models.Model):
@api.multi
def crear_exportacion(self):
self.exportacion = [(5),(0,0,{'invoice_id':self.id})]
self.exportacion = [(5,), (0,0,{
'pais_destino': self.commercial_partner_id.country_id.id,
})]
def _es_exportacion(self):
if self.sii_document_class_id.sii_code in [ 110, 111, 112 ]:
return True
return False
def _bultos(self, bultos):
Bultos = []
for b in bultos:
Bulto = dict()
Bulto['TipoBultos'] = collections.OrderedDict()
Bulto['TipoBultos']['CodTpoBultos'] = bultos.tipo_bulto.code
Bulto['TipoBultos']['CantBultos'] = bultos.cantidad_bultos
Bultos.append(Bulto)
return Bultos
def _aduana(self):
expo = self.exportacion
Aduana = collections.OrderedDict()
#if not in 3,4,5
Aduana['CodModVenta'] = self.payment_terms_id.forma_pago_aduanas.code
Aduana['CodClauVenta'] = self.incoterms_id.code
Aduana['TotClauVenta'] = self.payment_terms_id
Aduana['CodViaTransp'] = self.via.code
Aduana['NombreTransp'] = self.chofer_id.name
Aduana['RUTCiaTransp'] = self.format_vat(self.carrier_id.partner_id.vat)
Aduana['NomCiaTransp'] = self.carrier_id.name
Aduana['CodModVenta'] = self.payment_term_id.forma_pago_aduanas.code
if self.incoterms_id:
Aduana['CodClauVenta'] = self.incoterms_id.aduanas_code
mnt_clau = 0
Aduana['TotClauVenta'] = round(self.payment_term_id.compute(self.amount_total), 2)
if expo.via:
Aduana['CodViaTransp'] = expo.via.code
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)
if expo.carrier_id:
Aduana['NomCiaTransp'] = expo.carrier_id.name
#Aduana['IdAdicTransp'] = self.indicador_adicional
Aduana['CodPtoEmbarque'] = self.puerto_embarque.code
Aduana['IdAdicPtoEmb'] = self.ind_puerto_embarque
Aduana['CodPtoDesemb'] = self.puerto_desembarque.code
Aduana['IdAdicPtoDesemb'] = self.ind_puerto_desembarque
Aduana['Tara'] = self.tara
Aduana['CodUnidMedTara'] = self.uom_tara.name
Aduana['PesoBruto'] = self.peso_bruto
Aduana['CodUnidPesoBruto'] = self.uom_peso_bruto.name
Aduana['PesoNeto'] = self.peso_neto
Aduana['CodUnidPesoNeto'] = self.uom_peso_neto.name
Aduana['TotItems'] = self.total_items
Aduana['TotBultos'] = self.total_bultos
Aduana['TipoBultos'] = self.tipo_bulto.name
Aduana['CodTpoBultos'] = self.tipo_bulto.code
Aduana['CantBultos'] = self.cantidad_bultos
if expo.puerto_embarque:
Aduana['CodPtoEmbarque'] = expo.puerto_embarque.code
#Aduana['IdAdicPtoEmb'] = expo.ind_puerto_embarque
if expo.puerto_desembarque:
Aduana['CodPtoDesemb'] = expo.puerto_desembarque.code
#Aduana['IdAdicPtoDesemb'] = expo.ind_puerto_desembarque
if expo.tara:
Aduana['Tara'] = expo.tara
Aduana['CodUnidMedTara'] = expo.uom_tara.code
if expo.peso_bruto:
Aduana['PesoBruto'] = round(expo.peso_bruto, 2)
Aduana['CodUnidPesoBruto'] = expo.uom_peso_bruto.code
if expo.peso_neto:
Aduana['PesoNeto'] = round(expo.peso_neto, 2)
Aduana['CodUnidPesoNeto'] = expo.uom_peso_neto.code
if expo.total_items:
Aduana['TotItems'] = expo.total_items
if expo.total_bultos:
Aduana['TotBultos'] = expo.total_bultos
Aduana['item'] = self._bultos(expo.bultos)
#Aduana['Marcas'] =
#Solo si es contenedor
#Aduana['IdContainer'] =
#Aduana['Sello'] =
#Aduana['EmisorSello'] =
Aduana['MntFlete'] = self.monto_flete
Aduana['MntSeguro'] = self.monto_seguro
Aduana['CodPaisRecep'] = self.pais_recepcion.name
Aduana['CodPaisDestin'] = self.pais_destino.code
Aduana['MntFlete'] = expo.monto_flete
Aduana['MntSeguro'] = expo.monto_seguro
Aduana['CodPaisRecep'] = expo.pais_recepcion.name
Aduana['CodPaisDestin'] = expo.pais_destino.code
return Aduana
def _transporte(self):
Transporte = collections.OrderedDict()
if self.patente:
Transporte['Patente'] = self.patente[:8]
elif self.vehicle:
Transporte['Patente'] = self.vehicle.matricula or ''
if self.transport_type in ['2','3'] and self.chofer:
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)
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)
if self.chofer:
Transporte['Chofer'] = collections.OrderedDict()
Transporte['Chofer']['RUTChofer'] = self.format_vat(self.chofer.vat)
Transporte['Chofer']['NombreChofer'] = self.chofer.name[:30]
expo = self.exportacion
if expo.carrier_id:
if self.patente:
Transporte['Patente'] = self.patente[:8]
elif self.vehicle:
Transporte['Patente'] = self.vehicle.matricula or ''
if self.transport_type in ['2','3'] and self.chofer:
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)
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)
if self.chofer:
Transporte['Chofer'] = collections.OrderedDict()
Transporte['Chofer']['RUTChofer'] = self.format_vat(self.chofer.vat)
Transporte['Chofer']['NombreChofer'] = self.chofer.name[:30]
partner_id = self.partner_id or self.company_id.partner_id
Transporte['DirDest'] = (partner_id.street or '')+ ' '+ (partner_id.street2 or '')
Transporte['CmnaDest'] = partner_id.state_id.name or ''
......@@ -119,19 +146,6 @@ class Exportacion(models.Model):
Transporte['Aduana'] = self._aduana()
return Transporte
def _otra_moneda(self):
OtraMoneda = collections.OrderedDict()
OtraMoneda['TpoMoneda'] = self.currency_id
OtraMoneda['TpoCambio'] = self.currency_id.cambio
OtraMoneda['MntNetoOtrMnda'] = self.currency_id
OtraMoneda['MntExeOtrMnda'] = self.currency_id
#OtraMoneda['MntFaeCarneOtrMnda'] =
#OtraMoneda['MntMargComOtrMnda'] =
OtraMoneda['IVAOtrMnda'] = self.currency_id
#OtraMoneda[''] = otros impuestos otra moneda
OtraMoneda['MntTotOtrMnda'] = self.currency_id
return OtraMoneda
def _encabezado(self, MntExe=0, no_product=False, taxInclude=False):
res = super(Exportacion, self)._encabezado(MntExe, no_product, taxInclude)
if not self._es_exportacion():
......@@ -141,19 +155,6 @@ class Exportacion(models.Model):
result[key] = value
if key == 'Receptor':
result['Transporte'] = self._transporte()
if key == 'Totales':
result['OtraMoneda'] = self._otra_moneda()
return result
def _totales(self, MntExe=0, no_product=False, taxInclude=False):
res = super(Exportacion, self)._totales(MntExe, no_product, taxInclude)
if not self._es_exportacion():
return res
result = collections.OrderedDict()
result['TpoMoneda'] = self.compnay_id.currency_id.sii_code
for key, value in res.iteritems():
#if forma pago 21 mnttotal = 0
result[key] = value
return result
def _tpo_dte(self):
......
......@@ -12,7 +12,26 @@
<button name="crear_exportacion" type="object" string="Crear Exportación" />
</header>
<group>
<field name="exportacion" />
<field name="exportacion" editable="bottom" widget="one2many">
<tree editable="top/bottom">
<field name="pais_destino" />
<field name="puerto_embarque" />
<field name="puerto_desembarque" />
<field name="via"/>
<field name="carrier_id"/>
<field name="tara"/>
<field name="uom_tara" />
<field name="peso_bruto" />
<field name="uom_peso_bruto"/>
<field name="peso_neto"/>
<field name="uom_peso_neto"/>
<field name="total_items"/>
<field name="bultos"/>
<field name="monto_flete"/>
<field name="monto_seguro"/>
<field name="pais_recepcion"/>
</tree>
</field>
</group>
</page>
</notebook>
......
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