I find it difficult to work @ api.onchange.
here are my files
INIT .py
from . import models
manifest .py
{
'name': "Sales Test",
'description': 'test description',
'depends': ['sale'],
'category': 'Test',
'data': [
'views/templates.xml',
],
'installable': True,
'application': False,
'auto_install': False,
}
init .py (file in the model directory)
from . import partner
partner.py (file in the model directory)
from odoo import models, fields, api
class MyPartner(models.Model):
_inherit = 'res.partner'
@api.onchange('country_id')
def _onchange_country_id(self):
self.name = 'OnChange'
@api.onchange('street', 'zip')
def _onchange_street(self):
self.street = 'Test Street'
return {
'warning': {
'title': "Some changes happened",
'message': "onchange working, bravo!!!",
}
},
the module installs without any problems, and the view also changes according to the .XML templates, but nothing happens when the change occurs with the fields (street, country_id or zip)
source
share