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')]")




Portretas
Atmesti
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()


https://www.cybrosys.com/blog/how-to-use-of-name-get-function-in-odoo


And also you can go through our youtube video


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



Hope it helps

Portretas
Atmesti
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

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
0
spal. 23
1165
4
geg. 25
1615
0
gruod. 24
741
ODOO.sh Solved
2
spal. 24
12178
1
rugs. 24
1147