Skip to Content
Menu
This question has been flagged

Hi everyone, I have two fields related to the 'res.partner' that bring me the "child_ids" of the contacts that are invoice addresses and shipping addresses. The field works perfectly but as these addresses do not have a name as such, they only have data in the fields 'street', 'street2', 'country_id', 'state_id', 'city', and 'zip' when selecting an option they all appear as "Azure Interior - Billing Address" and "Azure Interior - Shipping Address" in this example. I need that when I select the options it shows me the information of the field 'street', 'street2' and 'city' concatenated or only the information in the field 'street' of res.partner. I attach my code and a screenshot so you can see it better:


from odoo import models, fields, api

class direcciones(models.Model):
_inherit = 'account.move'

direccion_factura = fields.Many2one('res.partner', string='Direccion de Facturacion', domain="['&','&',('is_company','=',False),('parent_id','=',partner_id),('type','=','invoice')]")

direccion_envio = fields.Many2one('res.partner', string='Direccion de Envio', domain="['&','&',('is_company','=',False),('parent_id','=',partner_id),('type','=','delivery')]")




Avatar
Discard
Best Answer

Hi,

In such cases odoo provides a default function ie,name_get().By using this function you can the information of the field 'street', 'street2' and 'city'..for reference you can refer our following blogs to know more about name_get()

Name_get() Function in Odoo 16
How to use name_get function in odoo


And also you can go through our youtube video

https://www.youtube.com/watch?v=kHq6nUwEGjM


Hope it helps

Avatar
Discard
Best Answer

A solution is to pass a context with the field in the QWEB XML.

The context value can then read extended in the "name_get" function on the res.partener where you can return the value in the format you need.

have a look at this for more details...  Link

I think this might also be doable via wedget

Avatar
Discard
Related Posts Replies Views Activity
0
Oct 23
1126
0
Dec 24
608
ODOO.sh Solved
2
Oct 24
12082
1
Sep 24
1001
0
Aug 24
682