Odoo Help

0

How to apply changes only to a customer when I inherit res_partner and make changes in create an write?

By
Sohail
on 6/1/13, 8:53 AM 1,523 views

The changes made in create and write of inherited res_partner should affect only the customer and not the supplier and user.

0
Dharmesh Rathod
On 6/1/13, 10:46 AM

Hi,

There is only one object "res.partner" which manage customer and supplier.

Email : info@acespritech.com
Skype : acespritech
Blog : acespritechblog.wordpress.com

0

patrick

--patrick--
1958
| 5 4 7
Baarn, Netherlands
--patrick--
patrick
On 6/1/13, 7:55 PM

Customer, supplier and user (and maybe other 'persons') use the same model 'res.partner'. In order for your model to only do something different for customer, you should ask in your write and your create, if the res.partner you are in, is a customer.

Some quick and dirty code:

def create(.....):
    partner = pool.get(id)
    if partner.is_customer and not partner.supplier:
        do your code here
    else:
        res = super(self, res.partner).create(.....)

The same goes for write.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 6/1/13, 8:53 AM
Seen: 1523 times
Last updated: 3/16/15, 8:10 AM