Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Daniel Santibáñez Polanco
l10n_cl_dte_exportacion
Commits
92e78cea
Commit
92e78cea
authored
Dec 26, 2019
by
Daniel Santibáñez Polanco
Browse files
[WIP]Migración a versión odoo 11.0 y facturacion_electronica
parent
b417fe7b
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
152 additions
and
112 deletions
+152
-112
__init__.py
__init__.py
+1
-1
__manifest__.py
__manifest__.py
+2
-3
models/__init__.py
models/__init__.py
+2
-2
models/account_invoice.py
models/account_invoice.py
+111
-74
models/account_invoice_exportacion.py
models/account_invoice_exportacion.py
+2
-1
models/aduanas_formas_pago.py
models/aduanas_formas_pago.py
+1
-1
models/aduanas_modalidades_venta.py
models/aduanas_modalidades_venta.py
+1
-1
models/aduanas_paises.py
models/aduanas_paises.py
+1
-1
models/aduanas_puertos.py
models/aduanas_puertos.py
+1
-1
models/aduanas_tipos_bulto.py
models/aduanas_tipos_bulto.py
+1
-1
models/aduanas_tipos_carga.py
models/aduanas_tipos_carga.py
+1
-1
models/aduanas_tipos_transporte.py
models/aduanas_tipos_transporte.py
+1
-1
models/payment_terms.py
models/payment_terms.py
+1
-1
models/product_uom.py
models/product_uom.py
+1
-1
models/stock_incoterms.py
models/stock_incoterms.py
+1
-1
views/invoice_exportacion.xml
views/invoice_exportacion.xml
+1
-0
views/invoice_view.xml
views/invoice_view.xml
+23
-21
No files found.
__init__.py
View file @
92e78cea
# -*- coding: utf-8 -*-
import
models
from
.
import
models
__
openerp
__.py
→
__
manifest
__.py
View file @
92e78cea
...
...
@@ -2,7 +2,7 @@
{
"name"
:
"""Factura de Exportación Electrónica para Chile
\
"""
,
'version'
:
'
9
.0.0.0.1'
,
'version'
:
'
11
.0.0.0.1'
,
'category'
:
'Localization/Chile'
,
'sequence'
:
12
,
'author'
:
'Daniel Santibáñez Polanco, Cooperativa OdooCoop'
,
...
...
@@ -16,8 +16,7 @@ Chile: Factura de Exportación Electrónica.
'product'
,
'stock'
,
'delivery'
,
'l10n_cl_dte'
,
'global_discount'
,
'l10n_cl_fe'
,
],
'data'
:
[
'views/aduanas_formas_pago.xml'
,
...
...
models/__init__.py
View file @
92e78cea
# -*- coding: utf-8 -*-
from
.
import
account_invoice
from
.
import
account_invoice_exportacion
from
.
import
aduanas_formas_pago
from
.
import
aduanas_modalidades_venta
from
.
import
aduanas_paises
...
...
@@ -7,7 +9,5 @@ from . import aduanas_tipos_bulto
from
.
import
aduanas_tipos_carga
from
.
import
aduanas_tipos_transporte
from
.
import
product_uom
from
.
import
invoice_exportacion
from
.
import
invoice
from
.
import
payment_terms
from
.
import
stock_incoterms
models/invoice.py
→
models/
account_
invoice.py
View file @
92e78cea
# -*- coding: utf-8 -*-
from
openerp
import
fields
,
models
,
api
,
_
from
openerp.exceptions
import
UserError
from
datetime
import
datetime
,
timedelta
,
date
import
os
from
odoo
import
fields
,
models
,
api
,
_
from
odoo.exceptions
import
UserError
import
logging
from
lxml
import
etree
from
lxml.etree
import
Element
,
SubElement
from
openerp
import
SUPERUSER_ID
import
pytz
import
collections
_logger
=
logging
.
getLogger
(
__name__
)
try
:
import
xmltodict
except
ImportError
:
_logger
.
warning
(
'Cannot import xmltodict library'
)
try
:
import
dicttoxml
except
ImportError
:
_logger
.
warning
(
'Cannot import dicttoxml library'
)
try
:
import
base64
except
ImportError
:
_logger
.
warning
(
'Cannot import base64 library'
)
class
Exportacion
(
models
.
Model
):
_inherit
=
"account.invoice"
exportacion
=
fields
.
One2many
(
string
=
"Exportación"
,
exportacion
=
fields
.
Many2one
(
string
=
"
Detalles
Exportación"
,
comodel_name
=
"account.invoice.exportacion"
,
inverse_name
=
"invoice_id"
,
context
=
{
"form_view_ref"
:
"l10n_cl_exportacion.exportacion_view_form"
},
help
=
"Explain your field."
,
readonly
=
True
,
states
=
{
'draft'
:
[(
'readonly'
,
False
)]},
)
pais_destino
=
fields
.
Many2one
(
'aduanas.paises'
,
related
=
"exportacion.pais_destino"
,
string
=
'País de Destino'
,
)
puerto_embarque
=
fields
.
Many2one
(
'aduanas.puertos'
,
related
=
"exportacion.puerto_embarque"
,
string
=
'Puerto Embarque'
,
)
puerto_desembarque
=
fields
.
Many2one
(
'aduanas.puertos'
,
related
=
"exportacion.puerto_desembarque"
,
string
=
'Puerto de Desembarque'
,
)
via
=
fields
.
Many2one
(
'aduanas.tipos_transporte'
,
related
=
"exportacion.via"
,
string
=
'Vía'
,
)
carrier_id
=
fields
.
Many2one
(
'delivery.carrier'
,
related
=
"exportacion.carrier_id"
,
string
=
"Transporte"
,
)
tara
=
fields
.
Integer
(
related
=
"exportacion.tara"
,
string
=
"Tara"
,
)
uom_tara
=
fields
.
Many2one
(
'product.uom'
,
related
=
"exportacion.uom_tara"
,
string
=
'Unidad Medida Tara'
,
)
peso_bruto
=
fields
.
Float
(
related
=
"exportacion.peso_bruto"
,
string
=
"Peso Bruto"
,
)
uom_peso_bruto
=
fields
.
Many2one
(
'product.uom'
,
related
=
"exportacion.uom_peso_bruto"
,
string
=
'Unidad Medida Peso Bruto'
,
)
peso_neto
=
fields
.
Float
(
related
=
"exportacion.peso_neto"
,
string
=
"Peso Neto"
,
)
uom_peso_neto
=
fields
.
Many2one
(
'product.uom'
,
related
=
"exportacion.uom_peso_neto"
,
string
=
'Unidad Medida Peso Neto'
,
)
total_items
=
fields
.
Integer
(
related
=
"exportacion.total_items"
,
string
=
"Total Items"
,
)
monto_flete
=
fields
.
Monetary
(
related
=
"exportacion.monto_flete"
,
string
=
"Monto Flete"
,
)
monto_seguro
=
fields
.
Monetary
(
related
=
"exportacion.monto_seguro"
,
string
=
"Monto Seguro"
,
)
pais_recepcion
=
fields
.
Many2one
(
'aduanas.paises'
,
related
=
"exportacion.pais_recepcion"
,
string
=
'País de Recepción'
,
)
picking_id
=
fields
.
Many2one
(
'stock.picking'
,
string
=
"Movimiento Relacionado"
)
def
format_vat
(
self
,
value
,
con_cero
=
False
):
if
self
.
_es_exportacion
()
and
self
.
commercial_partner_id
.
vat
==
value
:
if
self
.
_es_exportacion
()
and
self
.
partner_id
.
commercial_partner_id
.
vat
==
value
:
value
=
"CL555555555"
return
super
(
Exportacion
,
self
).
format_vat
(
value
,
con_cero
)
@
api
.
multi
def
crear_exportacion
(
self
):
self
.
exportacion
=
[(
5
,),
(
0
,
0
,{
'pais_destino'
:
self
.
commercial_partner_id
.
country_id
.
id
,
})]
self
.
exportacion
=
self
.
env
[
'account.invoice.exportacion'
].
create
({
'name'
:
'Exportación'
,
})
def
_es_nc_exportacion
(
self
):
return
self
.
sii_
document_class_id
.
sii_code
in
[
112
]
return
self
.
document_class_id
.
sii_code
in
[
112
]
def
_es_exportacion
(
self
):
if
self
.
sii_
document_class_id
.
sii_code
in
[
110
,
111
,
112
]:
if
self
.
document_class_id
.
sii_code
in
[
110
,
111
,
112
]:
return
True
return
False
def
_totales_normal
(
self
,
currency_id
,
MntExe
,
MntNeto
,
IVA
,
TasaIVA
,
ImptoReten
,
MntTotal
=
0
):
def
_totales_normal
(
self
,
currency_id
,
MntExe
,
MntNeto
,
IVA
,
TasaIVA
,
MntTotal
=
0
,
MntBase
=
0
):
if
not
self
.
_es_exportacion
():
return
super
(
Exportacion
,
self
).
_totales_normal
(
currency_id
,
MntExe
,
MntNeto
,
IVA
,
TasaIVA
,
ImptoReten
,
MntTotal
)
if
IVA
:
raise
UserError
(
"No debe haber Productos con IVA"
)
Totales
=
collections
.
OrderedDict
()
return
super
(
Exportacion
,
self
).
_totales_normal
(
currency_id
,
MntExe
,
MntNeto
,
IVA
,
TasaIVA
,
MntTotal
,
MntBase
)
Totales
=
{}
if
currency_id
:
Totales
[
'TpoMoneda'
]
=
currency_id
.
abreviatura
Totales
[
'MntExe'
]
=
MntExe
Totales
[
'MntTotal'
]
=
MntTotal
#Totales['MontoNF']
#Totales['TotalPeriodo']
#Totales['SaldoAnterior']
#Totales['VlrPagar']
return
Totales
def
_totales_otra_moneda
(
self
,
currency_id
,
MntExe
,
MntNeto
,
IVA
,
TasaIVA
,
ImptoReten
,
MntTotal
=
0
):
def
_totales_otra_moneda
(
self
,
currency_id
,
MntExe
,
MntNeto
,
IVA
,
TasaIVA
,
MntTotal
=
0
,
MntBase
=
0
):
if
not
self
.
_es_exportacion
():
return
super
(
Exportacion
,
self
).
_totales_otra_moneda
(
currency_id
,
MntExe
,
MntNeto
,
IVA
,
TasaIVA
,
ImptoReten
,
MntTotal
)
Totales
=
collections
.
OrderedDict
()
Totales
[
'TpoMoneda'
]
=
self
.
_acortar_str
(
self
.
company_id
.
currency_id
.
abreviatura
,
15
)
return
super
(
Exportacion
,
self
).
_totales_otra_moneda
(
currency_id
,
MntExe
,
MntNeto
,
IVA
,
TasaIVA
,
MntTotal
,
MntBase
)
Totales
=
{}
Totales
[
'TpoMoneda'
]
=
self
.
_acortar_str
(
currency_id
.
abreviatura
,
15
)
Totales
[
'TpoCambio'
]
=
currency_id
.
rate
if
MntExe
:
if
currency_id
:
...
...
@@ -99,28 +145,28 @@ class Exportacion(models.Model):
return
self
.
currency_id
.
round
(
MntExe
)
def
_totales
(
self
,
MntExe
=
0
,
no_product
=
False
,
taxInclude
=
False
):
MntExe
,
MntNeto
,
MntIVA
,
TasaIVA
,
ImptoReten
,
MntTotal
=
super
(
Exportacion
,
self
).
_totales
(
MntExe
,
no_product
,
taxInclude
)
MntExe
,
MntNeto
,
MntIVA
,
TasaIVA
,
MntTotal
,
MntBase
=
super
(
Exportacion
,
self
).
_totales
(
MntExe
,
no_product
,
taxInclude
)
if
self
.
_es_exportacion
():
MntExe
=
self
.
_aplicar_gdr
(
MntExe
)
return
MntExe
,
MntNeto
,
MntIVA
,
TasaIVA
,
ImptoReten
,
MntTotal
return
MntExe
,
MntNeto
,
MntIVA
,
TasaIVA
,
MntTotal
,
MntBase
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
Bulto
[
'CodTpoBultos'
]
=
bultos
.
tipo_bulto
.
code
Bulto
[
'CantBultos'
]
=
bultos
.
cantidad_bultos
Bultos
.
append
(
Bulto
)
return
Bultos
def
_aduana
(
self
):
expo
=
self
.
exportacion
Aduana
=
collections
.
OrderedDict
()
Aduana
=
{}
#if not in 3,4,5
if
self
.
payment_term_id
:
Aduana
[
'CodModVenta'
]
=
self
.
payment_term_id
.
forma_pago_aduanas
.
code
mnt_clau
=
self
.
payment_term_id
.
with_context
(
currency_id
=
self
.
currency_id
.
id
).
compute
(
self
.
amount_total
,
date_ref
=
self
.
date_invoice
)[
0
]
mnt_clau
=
self
.
payment_term_id
.
with_context
(
currency_id
=
self
.
currency_id
.
id
).
compute
(
self
.
amount_total
,
date_ref
=
self
.
date_invoice
)[
0
]
Aduana
[
'TotClauVenta'
]
=
round
(
mnt_clau
[
0
][
1
],
2
)
elif
not
self
.
_es_nc_exportacion
():
raise
UserError
(
"Debe Ingresar un Término de Pago"
)
...
...
@@ -154,7 +200,7 @@ class Exportacion(models.Model):
Aduana
[
'TotItems'
]
=
expo
.
total_items
if
expo
.
total_bultos
:
Aduana
[
'TotBultos'
]
=
expo
.
total_bultos
Aduana
[
'
item
'
]
=
self
.
_bultos
(
expo
.
bultos
)
Aduana
[
'
Bultos
'
]
=
self
.
_bultos
(
expo
.
bultos
)
#Aduana['Marcas'] =
#Solo si es contenedor
#Aduana['IdContainer'] =
...
...
@@ -171,24 +217,24 @@ class Exportacion(models.Model):
return
Aduana
def
_transporte
(
self
):
Transporte
=
collections
.
OrderedDict
()
Transporte
=
{}
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
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'
:
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'
]
=
{}
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
...
...
@@ -202,14 +248,5 @@ class Exportacion(models.Model):
res
=
super
(
Exportacion
,
self
).
_encabezado
(
MntExe
,
no_product
,
taxInclude
)
if
not
self
.
_es_exportacion
():
return
res
result
=
collections
.
OrderedDict
()
for
key
,
value
in
res
.
iteritems
():
result
[
key
]
=
value
if
key
==
'Receptor'
:
result
[
'Transporte'
]
=
self
.
_transporte
()
return
result
def
_tpo_dte
(
self
):
if
self
.
_es_exportacion
():
return
'Exportaciones'
return
super
(
Exportacion
,
self
).
_tpo_dte
()
res
[
'Transporte'
]
=
self
.
_transporte
()
return
res
models/invoice_exportacion.py
→
models/
account_
invoice_exportacion.py
View file @
92e78cea
# -*- coding: utf-8 -*-
from
openerp
import
fields
,
models
,
api
,
_
from
odoo
import
fields
,
models
,
api
,
_
class
Exportacion
(
models
.
Model
):
_name
=
"account.invoice.exportacion"
...
...
models/aduanas_formas_pago.py
View file @
92e78cea
# -*- coding: utf-8 -*-
from
o
penerp
import
fields
,
models
,
api
,
_
from
o
doo
import
fields
,
models
,
api
,
_
class
AduanasFormasPago
(
models
.
Model
):
_name
=
'aduanas.formas_pago'
...
...
models/aduanas_modalidades_venta.py
View file @
92e78cea
# -*- coding: utf-8 -*-
from
o
penerp
import
fields
,
models
,
api
,
_
from
o
doo
import
fields
,
models
,
api
,
_
class
AduanasModalidadesVenta
(
models
.
Model
):
_name
=
'aduanas.modalidades_venta'
...
...
models/aduanas_paises.py
View file @
92e78cea
# -*- coding: utf-8 -*-
from
o
penerp
import
fields
,
models
,
api
,
_
from
o
doo
import
fields
,
models
,
api
,
_
class
AduanasPaises
(
models
.
Model
):
_name
=
'aduanas.paises'
...
...
models/aduanas_puertos.py
View file @
92e78cea
# -*- coding: utf-8 -*-
from
o
penerp
import
fields
,
models
,
api
,
_
from
o
doo
import
fields
,
models
,
api
,
_
class
AduanasPuertos
(
models
.
Model
):
_name
=
'aduanas.puertos'
...
...
models/aduanas_tipos_bulto.py
View file @
92e78cea
# -*- coding: utf-8 -*-
from
o
penerp
import
fields
,
models
,
api
,
_
from
o
doo
import
fields
,
models
,
api
,
_
class
AduanasTiposBulto
(
models
.
Model
):
_name
=
'aduanas.tipos_bulto'
...
...
models/aduanas_tipos_carga.py
View file @
92e78cea
# -*- coding: utf-8 -*-
from
o
penerp
import
fields
,
models
,
api
,
_
from
o
doo
import
fields
,
models
,
api
,
_
class
AduansTiposCarga
(
models
.
Model
):
_name
=
'aduanas.tipos_carga'
...
...
models/aduanas_tipos_transporte.py
View file @
92e78cea
# -*- coding: utf-8 -*-
from
o
penerp
import
fields
,
models
,
api
,
_
from
o
doo
import
fields
,
models
,
api
,
_
class
AduanasTiposTransporte
(
models
.
Model
):
_name
=
'aduanas.tipos_transporte'
...
...
models/payment_terms.py
View file @
92e78cea
# -*- coding: utf-8 -*-
from
o
penerp
import
fields
,
models
,
api
,
_
from
o
doo
import
fields
,
models
,
api
,
_
class
PaymenTerms
(
models
.
Model
):
_inherit
=
"account.payment.term"
...
...
models/product_uom.py
View file @
92e78cea
# -*- coding: utf-8 -*-
from
o
penerp
import
fields
,
models
,
api
,
_
from
o
doo
import
fields
,
models
,
api
,
_
class
AduanasUnidadesMedida
(
models
.
Model
):
_inherit
=
'product.uom'
...
...
models/stock_incoterms.py
View file @
92e78cea
# -*- coding: utf-8 -*-
from
o
penerp
import
fields
,
models
,
api
,
_
from
o
doo
import
fields
,
models
,
api
,
_
class
Incoterms
(
models
.
Model
):
_inherit
=
"stock.incoterms"
...
...
views/invoice_exportacion.xml
View file @
92e78cea
...
...
@@ -24,6 +24,7 @@
<field
name=
"monto_seguro"
/>
<field
name=
"pais_recepcion"
/>
<field
name=
"invoice_id"
invisible=
"1"
/>
<field
name=
"bultos"
/>
</group>
</sheet>
</form>
...
...
views/invoice_view.xml
View file @
92e78cea
...
...
@@ -4,7 +4,7 @@
<record
id=
"view_exportacion_invoice_form"
model=
"ir.ui.view"
>
<field
name=
"model"
>
account.invoice
</field>
<field
name=
"name"
>
account.invoice.exportacion.form
</field>
<field
name=
"inherit_id"
ref=
"l10n_cl_
invoic
e.view_invoice_form"
/>
<field
name=
"inherit_id"
ref=
"l10n_cl_
f
e.view_invoice_form"
/>
<field
name=
"arch"
type=
"xml"
>
<notebook>
<page
string=
"Datos de Exportación"
name=
"exportacion"
>
...
...
@@ -12,26 +12,28 @@
<button
name=
"crear_exportacion"
type=
"object"
string=
"Crear Exportación"
/>
</header>
<group>
<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>
<field
name=
"exportacion"
/>
</group>
<group
string=
"Resumen Exportación"
>
<group>
<field
name=
"pais_destino"
/>
<field
name=
"puerto_embarque"
/>
<field
name=
"puerto_desembarque"
/>
<field
name=
"via"
/>
<field
name=
"pais_recepcion"
/>
</group>
<group>
<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=
"monto_flete"
/>
<field
name=
"monto_seguro"
/>
</group>
</group>
</page>
</notebook>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment