Odoo Help

0
0
Mohamed Sabry
On 12/7/18, 3:15 AM

Hi Pranav,

Thank you for your response.

Yes am using odoo classes, but sorry i didn't get why i have to inherit the phone.book? I need none of the fields declared in it,actually the other model in the second Module(waseel_crm) has its own fields. I just need the unlink function. And if i assumed that i will inherit to access the functions of the (phonebook.py) model why do i have to re-declare the unlink function after inheriting as you did?

So you are using same class in new module.

Just call self.unlink()

Pranav P S
on 12/8/18, 11:42 PM
0
subbarao
On 12/6/18, 8:20 AM

Hello Mohamed,

self.env['phone.book'].search([]).unlink()

inside search pass your domain or else it will call unlink() for all phonebook records

Don' t forgot add first module dependency on second module


 

0
Pranav P S
On 12/6/18, 8:05 AM

Hi Sabry,

As per my understanding you are using standard odoo class.

If you have defined class PhoneBook as standard odoo class(models.Model) you can inherit the class and call super function.
Eg:

class PhoneBook(models.Model):
    _name = 'phone.book'

    @api.multi

    def unlink(self):
        for rec in self:
            if rec.name == 'JOHN':
                raise NameError('Record with name John can\'t be deleted')


And in new python file inherit it



class PhoneBook(models.Model):
    _inherit = 'phone.book'


    @api.multi

    def unlink(self):
        for rec in self:
            if rec.name == 'JOHN':
                raise NameError('Record with name John can\'t be deleted')


Or else if you are using a normal python class you have to import it properly thats it.

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/6/18, 5:46 AM
Seen: 145 times
Last updated: 12/7/18, 3:15 AM