Skip to Content
Menu
This question has been flagged
1 Reply
5028 Views

I am working i on a project which goal is:

Project have two tables (account_invoice_tax and new_computed_stored)

I created a Class but is not working, please forgive my gross coding, I am newbie :)

class account_invoice_tax(models.Model):
_inherits = {'new.computed.stored':'new_id'}
_inherit = 'account.invoice.tax'
retencion_id = fields.Many2one('new.computed.stored',ondelete='cascade',required=True)
computed = fields.Char(string='Some_help', compute='_compute_new', help='Insert_Something', store=True)


@api.one
@api.depends('account_invoice_tax.amount')
def _compute_new(self):
    for record in self:
        record.computed = record.calculado * 2
# not relevant which formula used
Avatar
Discard
Author Best Answer

I found solution, I use not good the inheritance.

My solution was:

class account_invoice_tax(models.Model):
_inherit = 'account.invoice.tax'
x_tipo_impuesto = fields.Char('Tipo de Impuesto')
x_base_imponible = fields.Char('Base Imponible')
x_codigo_retencion = fields.Char('Código Retencion')
x_porcentaje_retencion = fields.Char('Porcentaje Retencion')
x_valor_retenido = fields.Float('Valor Retenido', compute='_compute_valor_retenido', digits=(12,2), store=True)
x_name = fields.Char('Item')
partner_id = fields.Char(string='Proveedor', store=True, related='invoice_id.partner_id.name')
retencion_id = fields.Many2one('modus.retenciones', 'Número de Retención', index=False)
ejercicio_fiscal = fields.Char('Ejercicio Fiscal')
base_imponible = fields.Float('Base Imponible', digits=(12,2), required=False)
codigo_impuesto = fields.Char('Código Impuesto')
impuesto_retencion = fields.Char('Impuesto')
porcent_retencion = fields.Float('Porcentaje Retención', digits=(3,0), required=False)
valor_retencion = fields.Float('Valor Retención', compute='_compute_valor_retencion', digits=(12,2), store=True)

@api.depends('base_imponible', 'porcent_retencion')
def _compute_valor_retencion(self):
    for record in self:
        record.valor_retencion = record.base_imponible * (record.porcent_retencion / 100)

@api.depends('amount')
def _compute_valor_retenido(self):
    for record in self:
        record.x_valor_retenido = record.amount * 2
Avatar
Discard
Related Posts Replies Views Activity
3
Apr 24
1024
0
May 24
46
1
Apr 24
1830
4
Sep 23
3085
2
Sep 23
5593