Commit e53e0a2e by Maria Agustina

1423

1 parent 7075e116
...@@ -11,10 +11,10 @@ class vnt_cobros(models.Model): ...@@ -11,10 +11,10 @@ class vnt_cobros(models.Model):
comodel_name='hgt.instituciones', comodel_name='hgt.instituciones',
) )
co_lin_deuda = fields.Many2many( co_lin_deuda = fields.One2many(
string=u"Línea Deuda", string=u"Línea Deuda",
comodel_name='vnt.linea_deuda', comodel_name='vnt.linea_deuda',
relation="cobro_lin_deuda", inverse_name='ld_cobros',
) )
co_resumen = fields.Text( co_resumen = fields.Text(
...@@ -23,6 +23,8 @@ class vnt_cobros(models.Model): ...@@ -23,6 +23,8 @@ class vnt_cobros(models.Model):
co_total_deuda = fields.Float( co_total_deuda = fields.Float(
string="Total Deuda", string="Total Deuda",
compute="_compute_co_total_deuda",
) )
co_total_interes = fields.Float( co_total_interes = fields.Float(
...@@ -31,8 +33,26 @@ class vnt_cobros(models.Model): ...@@ -31,8 +33,26 @@ class vnt_cobros(models.Model):
co_total = fields.Float( co_total = fields.Float(
string="Total", string="Total",
compute="_compute_co_total",
) )
#Calculos de totales
@api.depends('co_lin_deuda')
def _compute_co_total_deuda(self):
sumita = 0
for record in self:
for lin in record.co_lin_deuda:
if lin.ld_select == True:
sumita += lin.ld_total
record.co_total_deuda = sumita
@api.depends('co_total_deuda', 'co_total_interes')
def _compute_co_total(self):
sumita = 0
for record in self:
record.co_total = record.co_total_deuda + record.co_total_interes
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from odoo import models, fields, api, exceptions from odoo import models, fields, api, exceptions
from odoo.exceptions import UserError, ValidationError
import odoo.addons.decimal_precision as dp
import math
import os
class asw_comprobante(models.Model): class asw_comprobante(models.Model):
_inherit = 'asw.comprobante' _inherit = 'asw.comprobante'
comp_lin_deuda = fields.Many2one(
string=u'Linea Deuda',
comodel_name='vnt.linea_deuda',
ondelete='set null',
)
nd_lin_deuda = fields.Many2one(
string=u'Linea Deuda',
comodel_name='vnt.linea_deuda',
ondelete='set null',
)
\ No newline at end of file \ No newline at end of file
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#from odoo.exceptions import UserError from odoo import models, fields, api, exceptions
from odoo import models, fields, api from odoo.exceptions import UserError, ValidationError
#from datetime import datetime
import odoo.addons.decimal_precision as dp
import math
import os
class vnt_linea_deuda(models.Model): class vnt_linea_deuda(models.Model):
_name = 'vnt.linea_deuda' _name = 'vnt.linea_deuda'
#hacer dominio solo facturas emitidas, ventas ld_factura = fields.Many2one(
ld_factura = fields.One2many(
string='Factura', string='Factura',
comodel_name='asw.comprobante', comodel_name='asw.comprobante',
inverse_name='comp_lin_deuda', ondelete='restrict',
) required=True,
)
ld_fecha_vto = fields.Datetime( ld_fecha_vto = fields.Datetime(
string=u'Fecha de Vencimiento', string=u'Fecha de Vencimiento',
...@@ -23,17 +26,59 @@ class vnt_linea_deuda(models.Model): ...@@ -23,17 +26,59 @@ class vnt_linea_deuda(models.Model):
related='ld_factura.comp_estado', related='ld_factura.comp_estado',
) )
ld_total = fields.Monetary( ld_total = fields.Float(
string=u'Total Factura', string=u'Total Factura',
related='ld_factura.comp_total', compute="_compute_ld_total",
) )
#no pude hacer funcionar la cosa como monetary, tuve q hacer el campo total como float
# ld_total = fields.Monetary(
# string=u'Total Factura',
# related='ld_factura.comp_total',
# )
# ld_moneda = fields.Many2one(
# string=u'Moneda',
# related='ld_factura.comp_moneda',
# )
# ld_moneda = fields.Many2one(
# string=u'Moneda',
# comodel_name='res.currency',
# ondelete='set null',
# default=lambda self: self.env.user.company_id.currency_id.id,
# )
ld_select = fields.Boolean( ld_select = fields.Boolean(
string="Seleccionar", string="Seleccionar",
) )
ld_nd = fields.One2many( ld_nd = fields.Many2one(
string='Nota Débito', string='Nota Débito',
comodel_name='asw.comprobante', comodel_name='asw.comprobante',
inverse_name='nd_lin_deuda',
)
\ No newline at end of file \ No newline at end of file
ondelete='restrict',
required=True,
)
ld_cobros = fields.Many2one(
string='Cobros',
comodel_name='vnt.cobros',
ondelete='set null',
)
#calculo del total de la factura a traves de comp_total
@api.depends('ld_factura')
def _compute_ld_total(self):
for record in self:
record.ld_total = record.ld_factura.comp_total
#dominio p elegir solo facturas de venta
@api.onchange('ld_factura')
def onchange_ld_factura(self):
result = {}
result['domain'] = []
comp_venta_em = self.env['asw.comprobante'].search([('comp_talonario.tal_menu','=','fac'),('comp_tipo_comp','=','e')])
result['domain'] = {'ld_factura' : [('id', 'in', comp_venta_em.ids)]}
return result
...@@ -46,20 +46,23 @@ ...@@ -46,20 +46,23 @@
<notebook colspan="4"> <notebook colspan="4">
<page string="Deudas"> <page string="Deudas">
<field nolabel="1" name="co_lin_deuda"> <field nolabel="1" name="co_lin_deuda">
<tree create="0" delete="0" edit="0" editable="top"> <tree create="1" edit="1" editable="1">
<field name="ld_factura" /> <field name="ld_factura" />
<field name="ld_fecha_vto" /> <field name="ld_fecha_vto"/>
<field name="ld_estado" /> <field name="ld_estado"/>
<field name="ld_total" /> <field name="ld_total"/>
<field name="ld_select" /> <!-- <field name="ld_fecha_vto" editable="0" readonly="1" />
<field name="ld_estado" editable="0" readonly="1" />
<field name="ld_total" readonly="1" /> -->
<field name="ld_select"/>
</tree> </tree>
</field> </field>
</page> </page>
</notebook> </notebook>
<group name='total' class="oe_subtotal_footer oe_right"> <group name='total' class="oe_subtotal_footer oe_right">
<field name="co_total_deuda" /> <field name="co_total_deuda" readonly="1" />
<field name="co_total_interes" /> <field name="co_total_interes" readonly="1" />
<field name="co_total" /> <field name="co_total" readonly="1" />
</group> </group>
<!--</sheet>--> <!--</sheet>-->
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!