Hi All,
How to create function field for many2one or one2many.
Can any one suggest me with example, please
Thanks
Hi All,
How to create function field for many2one or one2many.
Can any one suggest me with example, please
Thanks
Hi Babu,
This can be implemented as follows. In old api,
def _get_default_address(self, cr, uid, ids, field_name, arg, context=None):
res = {}
partner_obj = self.pool.get('res.partner')
for data in self.browse(cr, uid, ids, context=context):
adr_id = False
if data.partner_id:
adr_id = partner_obj.address_get(cr, uid, [data.partner_id.id], ['contact'])['contact']
res[data.id] = adr_id
return res
_columns ={
'default_address_id': fields.function(_get_default_address, type="many2one", relation="res.partner"),
}
In new api, it will be as follows:
default_address_id = fields.Many2one(compute="_get_default_address", relation="res.partner")
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden| Gerelateerde posts | Antwoorden | Weergaven | Activiteit | |
|---|---|---|---|---|
|
1
mrt. 23
|
4813 | |||
|
0
dec. 22
|
5517 | |||
|
0
jun. 21
|
4752 | |||
|
0
jun. 20
|
8108 | |||
|
One2many or many2one
Opgelost
|
1
nov. 19
|
4401 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.
Can you explain where you want to use it ?