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

[IMP]Factura exportación, según versión 0.18.0

Se necesita facturacion_electronica == 0.9.4+
parent 0a460ee8
......@@ -2,7 +2,7 @@
{
"name": """Factura de Exportación Electrónica para Chile\
""",
'version': '11.0.0.0.1',
'version': '11.0.18.0.0',
'category': 'Localization/Chile',
'sequence': 12,
'author': 'Daniel Santibáñez Polanco, Cooperativa OdooCoop',
......
......@@ -70,6 +70,10 @@ class Exportacion(models.Model):
related="exportacion.total_items",
string="Total Items",
)
total_bultos = fields.Integer(
related="exportacion.total_bultos",
string="Total Bultos",
)
monto_flete = fields.Monetary(
related="exportacion.monto_flete",
string="Monto Flete",
......@@ -89,7 +93,7 @@ class Exportacion(models.Model):
)
def format_vat(self, value, con_cero=False):
if self._es_exportacion() and self.partner_id.commercial_partner_id.vat == value:
if self[0]._es_exportacion() and self[0].partner_id.commercial_partner_id.vat == value:
value = "CL555555555"
return super(Exportacion, self).format_vat(value, con_cero)
......@@ -97,10 +101,11 @@ class Exportacion(models.Model):
def crear_exportacion(self):
self.exportacion = self.env['account.invoice.exportacion'].create({
'name': 'Exportación',
'currency_id': self.currency_id.id,
})
def _es_nc_exportacion(self):
return self.document_class_id.sii_code in [ 112 ]
return self.document_class_id.sii_code in [111, 112]
def _es_exportacion(self):
if self.document_class_id.sii_code in [ 110, 111, 112 ]:
......@@ -147,12 +152,18 @@ class Exportacion(models.Model):
Totales['MntTotOtrMnda'] = MntTotal
return Totales
def _id_doc(self, taxInclude=False, MntExe=0):
res = super(Exportacion, self)._id_doc(taxInclude, MntExe)
res['FmaPagExp'] = self.payment_term_id.forma_pago_aduanas.code
return res
def _bultos(self, bultos):
Bultos = []
for b in bultos:
Bulto = dict()
Bulto['CodTpoBultos'] = bultos.tipo_bulto.code
Bulto['CantBultos'] = bultos.cantidad_bultos
Bulto['CodTpoBultos'] = b.tipo_bulto.code
Bulto['CantBultos'] = b.cantidad_bultos
Bulto['Marcas'] = b.marcas
Bultos.append(Bulto)
return Bultos
......@@ -255,3 +266,17 @@ class Exportacion(models.Model):
MntTotal, MntBase)
res['Transporte'] = self._transporte()
return res
@api.onchange('global_descuentos_recargos')
def _set_seguros(self):
_logger.warning("expo")
mnt_seguro = 0
mnt_flete = 0
if self.exportacion:
for gdr in self.global_descuentos_recargos:
if gdr.aplicacion == 'flete':
mnt_flete += gdr.valor
elif gdr.aplicacion == 'seguro':
mnt_seguro += gdr.valor
self.exportacion.monto_flete = mnt_flete
self.exportacion.monto_seguro = mnt_seguro
# -*- coding: utf-8 -*-
from odoo import fields, models, api, _
import logging
_logger = logging.getLogger(__name__)
class Exportacion(models.Model):
_name = "account.invoice.exportacion"
@api.depends('bultos')
@api.onchange('bultos')
def total_bultos(self):
@api.depends('bultos')
def tot_bultos(self):
for r in self:
_logger.warning(r)
tot_bultos = 0
for b in r.bultos:
tot_bultos += b.cantidad_bultos
r.total_bultos = tot_bultos
@api.depends('invoice_id.global_descuentos_recargos')
def _get_tot_from_recargos(self):
for r in self:
mnt_seguro = 0
mnt_flete = 0
for gdr in r.invoice_id.global_descuentos_recargos:
if gdr.aplicacion == 'flete':
mnt_flete += gdr.valor
elif gdr.aplicacion == 'seguro':
mnt_seguro += gdr.valor
r.monto_flete = mnt_flete
r.monto_seguro = mnt_seguro
pais_destino = fields.Many2one(
'aduanas.paises',
string='País de Destino',
......@@ -43,8 +34,7 @@ class Exportacion(models.Model):
)
total_bultos = fields.Integer(
string="Total Bultos",
compute='total_bultos',
store=True,
compute='tot_bultos',
)
bultos = fields.One2many(
string="Bultos",
......@@ -82,11 +72,9 @@ class Exportacion(models.Model):
)
monto_flete = fields.Monetary(
string="Monto Flete",
compute='_get_tot_from_recargos',
)
monto_seguro = fields.Monetary(
string="Monto Seguro",
compute='_get_tot_from_recargos',
)
pais_recepcion = fields.Many2one(
'aduanas.paises',
......@@ -96,20 +84,14 @@ class Exportacion(models.Model):
'res.partner',
string="Chofer"
)
invoice_id = fields.Many2one(
'account.invoice',
string="Factura",
ondelete="cascade",
)
currency_id = fields.Many2one(
'res.currency',
related='invoice_id.currency_id',
string='Moneda'
)
@api.onchange('carrier_id')
def set_chofer(self):
if not self.chofer_id:
if self.carrier_id and not self.chofer_id:
self.chofer_id = self.carrier_id.partner_id
@api.onchange('pais_destino')
......@@ -127,6 +109,9 @@ class Bultos(models.Model):
cantidad_bultos = fields.Integer(
string="Cantidad de Bultos",
)
marcas = fields.Char(
string="Identificación de marcas",
)
exportacion_id = fields.Many2one(
'account.invoice.exportacion',
)
......@@ -23,8 +23,9 @@
<field name="monto_flete"/>
<field name="monto_seguro"/>
<field name="pais_recepcion"/>
<field name="invoice_id" invisible="1"/>
<field name="total_bultos"/>
<field name="bultos" />
</group>
</sheet>
</form>
......@@ -40,6 +41,7 @@
<group>
<field name="tipo_bulto"/>
<field name="cantidad_bultos"/>
<field name="marcas" />
</group>
</sheet>
</form>
......
......@@ -31,8 +31,9 @@
<field name="peso_neto"/>
<field name="uom_peso_neto"/>
<field name="total_items"/>
<field name="monto_flete"/>
<field name="monto_seguro"/>
<field name="total_bultos"/>
<field name="monto_flete" readonly="1"/>
<field name="monto_seguro" readonly="1"/>
</group>
</group>
</page>
......
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