How to apply changes only to a customer when I inherit res_partner and make changes in create an write?
The changes made in create and write of inherited res_partner should affect only the customer and not the supplier and user.
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.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 6/1/13, 8:53 AM|
|Seen: 1351 times|
|Last updated: 3/16/15, 8:10 AM|