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

[FIX]Caso en que se agrega bultos y adopta a otros

parent d99837bf
......@@ -2,7 +2,7 @@
{
"name": """Factura de Exportación Electrónica para Chile\
""",
'version': '0.18.3',
'version': '0.18.4',
'category': 'Localization/Chile',
'sequence': 12,
'author': 'Daniel Santibáñez Polanco, Cooperativa OdooCoop',
......
# -*- coding: utf-8 -*-
from . import account_invoice
from . import account_invoice_bultos
from . import account_invoice_exportacion
from . import aduanas_formas_pago
from . import aduanas_modalidades_venta
......
......@@ -90,9 +90,11 @@ class Exportacion(models.Model):
)
bultos = fields.One2many(
string="Bultos",
comodel_name="account.invoice.exportacion.bultos",
inverse_name="exportacion_id",
related='exportacion.bultos',
comodel_name="account.invoice.bultos",
inverse_name="invoice_id",
readonly=True,
states={'draft': [('readonly', False)]},
copy=False,
)
picking_id = fields.Many2one(
'stock.picking',
......@@ -294,7 +296,7 @@ class Exportacion(models.Model):
Aduana['TotItems'] = expo.total_items
if expo.total_bultos:
Aduana['TotBultos'] = expo.total_bultos
Aduana['Bultos'] = self._bultos(expo.bultos)
Aduana['Bultos'] = self._bultos(self.bultos)
#Aduana['Marcas'] =
#Solo si es contenedor
#Aduana['IdContainer'] =
......@@ -394,7 +396,10 @@ class Exportacion(models.Model):
@api.onchange('bultos')
def tot_bultos(self):
self.exportacion.tot_bultos()
tot_bultos = 0
for b in self.bultos:
tot_bultos += b.cantidad_bultos
self.total_bultos = tot_bultos
@api.onchange('currency_id')
def update_exportacion(self):
......
# -*- coding: utf-8 -*-
from odoo import fields, models, api, _
import logging
_logger = logging.getLogger(__name__)
class Bultos(models.Model):
_name = 'account.invoice.bultos'
_description = "Bultos de la exportación"
invoice_id = fields.Many2one(
'account.invoice',
)
tipo_bulto = fields.Many2one(
'aduanas.tipos_bulto',
string='Tipo de Bulto',
)
tipo_bulto_code = fields.Char(
related="tipo_bulto.code"
)
cantidad_bultos = fields.Integer(
string="Cantidad de Bultos",
)
marcas = fields.Char(
string="Identificación de marcas",
)
id_container = fields.Char(
string="Id Container"
)
sello = fields.Char(
string="Sello"
)
emisor_sello = fields.Char(
string="Emisor Sello"
)
......@@ -6,16 +6,7 @@ _logger = logging.getLogger(__name__)
class Exportacion(models.Model):
_name = "account.invoice.exportacion"
@api.onchange('bultos')
@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
_description = "Detalle Exportacion"
pais_destino = fields.Many2one(
'aduanas.paises',
......@@ -34,13 +25,7 @@ class Exportacion(models.Model):
)
total_bultos = fields.Integer(
string="Total Bultos",
compute='tot_bultos',
)
bultos = fields.One2many(
string="Bultos",
comodel_name="account.invoice.exportacion.bultos",
inverse_name="exportacion_id",
)
via = fields.Many2one(
'aduanas.tipos_transporte',
string='Vía',
......@@ -98,33 +83,3 @@ class Exportacion(models.Model):
def set_recepcion(self):
if not self.pais_recepcion:
self.pais_recepcion = self.pais_destino
class Bultos(models.Model):
_name = 'account.invoice.exportacion.bultos'
_description = "Bultos de la exportación"
exportacion_id = fields.Many2one(
'account.invoice.exportacion',
)
tipo_bulto = fields.Many2one(
'aduanas.tipos_bulto',
string='Tipo de Bulto',
)
tipo_bulto_code = fields.Char(
related="tipo_bulto.code"
)
cantidad_bultos = fields.Integer(
string="Cantidad de Bultos",
)
marcas = fields.Char(
string="Identificación de marcas",
)
id_container = fields.Char(
string="Id Container"
)
sello = fields.Char(
string="Sello"
)
emisor_sello = fields.Char(
string="Emisor Sello"
)
......@@ -15,5 +15,5 @@ edit_aduanas_paises,edit_aduanas_paises,model_aduanas_paises,account.group_accou
access_aduanas_paises,access_aduanas_paises,model_aduanas_paises,,1,0,0,0
edit_account_invoice_exportacion,edit_account_invoice_exportacion,model_account_invoice_exportacion,account.group_account_invoice,1,1,1,1
access_account_invoice_exportacion,access_account_invoice_exportacion,model_account_invoice_exportacion,,1,0,0,0
edit_account_invoice_exportacion_bultos,edit_account_invoice_exportacion_bultos,model_account_invoice_exportacion_bultos,account.group_account_invoice,1,1,1,1
access_account_invoice_exportacion_bultos,access_account_invoice_exportacion_bultos,model_account_invoice_exportacion_bultos,,1,0,0,0
edit_account_invoice_bultos,edit_account_invoice_bultos,model_account_invoice_bultos,account.group_account_invoice,1,1,1,1
access_account_invoice_bultos,access_account_invoice_bultos,model_account_invoice_bultos,,1,0,0,0
......@@ -23,9 +23,7 @@
<field name="monto_seguro"/>
<field name="pais_recepcion"/>
<field name="total_bultos"/>
<field name="bultos" />
<field name="currency_id" />
</group>
</sheet>
</form>
......@@ -34,7 +32,7 @@
<record id="bultos_view_form" model="ir.ui.view">
<field name="name">bultos.form</field>
<field name="model">account.invoice.exportacion.bultos</field>
<field name="model">account.invoice.bultos</field>
<field name="arch" type="xml">
<form string="Bultos">
<sheet>
......@@ -46,7 +44,7 @@
<field name="id_container" attrs="{'invisible': [('tipo_bulto_code', 'not in', ['75', '78'])], 'required': ('tipo_bulto_code', 'in', ['75', '78'])}" />
<field name="sello" attrs="{'invisible': [('tipo_bulto_code', 'not in', ['75', '78'])], 'required': ('tipo_bulto_code', 'in', ['75', '78'])}" />
<field name="emisor_sello" attrs="{'invisible': [('tipo_bulto_code', 'not in', ['75', '78'])]}" />
<field name="exportacion_id" invisible="1"/>
<field name="invoice_id" invisible="1"/>
</group>
</sheet>
</form>
......
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