Hi, Juan Carlos again...
As you know, I'm new in Odoo, and I would learn a lot.
Ok I'm tryin to create a On change with my field many2one, I try to learn onchange, but is very difficult for me, help please.
my.py
class DetalleFactura(models.Model):
_name = "openacademy.detalle"
def onchange_producto_id(self,cr,uid,ids, producto_id,context=None):
precio = self.pool.get('product.product', 'price')
return {precio}
name = fields.Char(string="Titulo")
producto_id = fields.Many2one('product.product', 'Producto')
precio = fields.Float(string="Precio", readonly=True)
my.xml
<tree editable="bottom">
<field name="producto_id"/>
<field name="precio" on_change="onchange_producto_id(producto_id)"/>
</tree>
I use this code, but don't change the price value...
Thanks for the answers, I have an error with def onchange_productp_id(self): File "/opt/odoo/odoo/addons/openacademy/models.py", line 47 def onchange_producto_id(self): ^ IndentationError: unindent does not match any outer indentation level
Already solved it, sorry, and how I get the price of the product. I don't understand where is the parameters for on change functions... I read in ORM instructions, but is not all the information. My code: @api.onchange('producto_id') def _onchange_producto_id(self): if self.producto_id: self.precio = 100.00