Hello, I am trying to override a create method for the crm.leads model, but cant seem to get the overridden method to be called instead of the original.
Can someone tell me how to override another method from an inherited module?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello, I am trying to override a create method for the crm.leads model, but cant seem to get the overridden method to be called instead of the original.
Can someone tell me how to override another method from an inherited module?
Example:
my_module.py file:
class my_crm_lead(base_stage, format_address, osv.osv):
_inherit='crm.lead'
def create(self, cr, uid, vals, context=None):
if context is None:
context = {}
create_context = dict(context)
return super(crm_lead, self).create(cr, uid, vals, context=create_context)
my_crm_lead() #call the class it's required
__init__.py file:
import my_module
__openerp__.py file:
{
'name': 'My CRM',
'version': '1.0',
'category': '...',
'description':"...",
'depends': ['crm'],
'installable': True,
}
Hello, and thanks for your help. I forgot to import the class file in the __init__.py file. Once I did that then it worked
Hello Eric. Please, could you mark my answer as the correct?
You need to add the original module on openerp "Depends" List file. In that case i think is the crm.
Hope it helps.
What Rafael Reuber says it's true, but call the function (point number 2) it's not necessary.
Andrea
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Feb 18
|
32445 | ||
|
0
Apr 15
|
3074 | ||
|
0
Oct 24
|
571 | ||
|
3
Jul 18
|
3242 | ||
|
0
Feb 17
|
5 |