linea_deuda.py
2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# -*- coding: utf-8 -*-
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 vnt_linea_deuda(models.Model):
_name = 'vnt.linea_deuda'
ld_factura = fields.Many2one(
string='Factura',
comodel_name='asw.comprobante',
ondelete='restrict',
required=True,
)
ld_fecha_vto = fields.Datetime(
string=u'Fecha de Vencimiento',
related='ld_factura.comp_fecha_cancelacion'
)
ld_estado = fields.Selection(
string=u'Estado Factura',
related='ld_factura.comp_estado',
)
ld_total = fields.Float(
string=u'Total Factura',
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(
string="Seleccionar",
)
ld_nd = fields.Many2one(
string='Nota Débito',
comodel_name='asw.comprobante',
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