Calling a function from one module to another
I have two module the first has a phonebook.py file in the models folder with a class name PhoneBook. This PhoneBook class has a function unlink, which overrides the default unlink function of the model, with the following code:
for rec in self:
if rec.name == 'JOHN':
raise NameError('Record with name John can\'t be deleted')
Now in the second module I want to use this unlink function in my models.py file.
I used this import statement in my model.py, (from odoo.custom_modules.waseel_crm.models import phonebook). Where waseel_crm is the first module name and i added this code:
imp = phonebook.PhoneBook()
For some reason there is some error and the module is not able to see the function, am wondering what is wrong with what i did!
Thanks in advance.