Hi All,
How to create function field for many2one or one2many.
Can any one suggest me with example, please
Thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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")
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Mar 23
|
788 | ||
|
0
Dec 22
|
1516 | ||
|
0
Jun 21
|
1843 | ||
|
0
Jun 20
|
4179 | ||
One2many or many2one
Solved
|
|
1
Nov 19
|
1743 |
Can you explain where you want to use it ?