I'm having an issue right now with the behavior of api.onchange with a Many2one Field, Right now i have a code that generetes a record of 'orders.products.attributes', I need to trigger the api.onchange when the name of the record changes, for example:
class OrdersProducts(models.Model): products_attributes = fields.Many2one('orders.products.attributes', domain="[('order_product_id', '=', 0)]" ) price_with_extra = fields.Float() @api.onchange('products_attributes.name') #This is not working either
@api.onchange('products_attributes')#This is not triggered
def _get_price_extra(self):
for record in self:
record.price_with_extra = record.products_attributes.product_with_extracentralista_products_view.xml
<record id="orders_product_tree_view" model="ir.ui.view">
<field name="name">orders.products.tree.view</field>
<field name="model">orders.products</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="product_id" widget="many2one" string="Producto" attrs="{'readonly':[('pricelist_id', '=', False)]}"/>
<field name="products_attributes" widget="many2one" string="Descripcion" options="{'no_quick_create': True, 'no_create': True, 'no_click': True}" context="{'product': product_id, 'price': price}"/>
<field name="price_with_extra" string="Precio Unit." readonly="1"/>
</tree>
</field>
</record>