Hello
How can I show in the view: id = "product_template_product_form_view" the total field = fields.Float ('total', compute = '_ getamount') of class class AccountTax (models.Model) ?
this is my code:
ratio.py :
from odoo import fields, models, api, tools
class ProductTemplate(models.Model):
_name = 'product.template'
_inherit = 'product.template'
pventa_iva = fields.Float('PVP (IVA)')
pcompra_iva = fields.Float('COSTE (IVA)')
ratio = fields.Float('Ratio')
iva = fields.Integer('datos iva', compute='_venta_iva')
cant = fields.Many2many(comodel_name='account.tax', string='Tasas')
impuestos = fields.Float(compute='_compute_impuestos')
@api.depends('taxes_id')
def _venta_iva(self):
for record in self:
record.iva = record.taxes_id
class AccountTax(models.Model):
_name = 'account.tax'
_inherit = 'account.tax'
total = fields.Float('total', compute='_getamount')
@api.depends('amount')
def _getamount(self):
for record in self:
record.total = record.amount
And this is my view:<record id="product_template_product_form_view" model="ir.ui.view">
<field name="name">product.template.product.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<field name="list_price" position="before">
<field name="ratio"/>
<!-- <field name="amount" ref="account.view_tax_form"/> -->
</field>
<field name="list_price" position="after">
<field name="pventa_iva"/>
</field>
<field name="uom_id" position="before">
<field name="pcompra_iva"/>
<field name="iva"/>
<span t-esc="o._getamount"/>
<!-- <field name="total" ref="vista_iva"/>-->
<field name="cant"/>
<field name="impuestos"/>
<field name="taxes_id" widget="many2many_tags" on_change="1" can_create="true" can_write="true" modifiers="{}"/>
</field>
</field>
</record>
<record id="vista_iva" model="ir.ui.view">
<field name="name">vista.iva</field>
<field name="model">account.tax</field>
<field name="inherit_id" ref="account.view_tax_form"/>
<field name="arch" type="xml">
<field name="amount" position="after">
<field name="total"/>
</field>
</field>
</record>
Would you please share the issue you are facing in this code?