Help

0

How to add address functionality to an custom model?

Avatar
Mike clarke

Hi all,


I have a custom class that has address fields. I would like to integrate this model into the address handling plumbing in Odoo. How do I do this?

I have standard address fields in my class such as street, street2, country_id, state_id, city, and phone. This custom class does not inherit any base class.


If I use the Contact widget I don't get the address displaying correctly. I have been examining the code to find out how the "address" field which the contact widget uses is generated but I am lost as to how ti all fits together.

I have looked at the "format.address.mixin" but my class does not inherit res_partner. I also looked at "ir.qweb.field.contact". I haven't been able to determine if there is a function I need to override to provide the dynamic field "address" or what special fields there may be. From what I can gather there is some api to getting the address format from the country settings.


Any pointers on how address generation and formatting work in Odoo will be appreciated.



Avatar
Discard
1 Answer
0
Avatar
Mike clarke
Best Answer

So after some additional spelunking it appears that one needs to override the "name_get" api function to return the address from your class.  If this is already overridden I am not sure what one would do other than not use the widget and just code the template oneself.  Best to modify the functions from res_partner like "_display_address" and "name_get"

Avatar
Discard