Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
2244 Vistas

I wonder how can access sale order tags from stock.picking model. I tried to search for sale order and add it with compute field but, I'm getting `You are not allowed to access 'Unknown' (_unknown) records.`

in sale model:

inherited_tag_ids = fields.Many2many(compute="get_sale_order_tags")
def get_sale_order_tags(self):
"""Sends carrier data"""
self
.ensure_one()
return self.env['sale.order'].search(
[('state', '!=', 'cancel'), ('name', '=', self.origin)]).tag_ids


How can I access sale order tags from stock.picking model, maybe there is easy way, to do this?

Avatar
Descartar
Mejor respuesta

Hi,

You haven't specified the many2many model in your code

Try the solution below:

inherited_tag_ids = fields.Many2many('crm.tag', compute="get_sale_order_tags")

def get_sale_order_tags(self):
"""Sends carrier data"""
for
rec in self:
rec.inherited_tag_ids = self.env['sale.order'].search(
[('state', '!=', 'cancel'), ('name', '=', rec.origin)]).tag_ids

Thank you

Avatar
Descartar
Autor

this answer is correct, only you need to change 'crm.tag' to 'sale.order'

the tag_ids field in the sale.order model is related to crm.tag

Publicaciones relacionadas Respuestas Vistas Actividad
0
jun 23
2322
0
sept 17
4784
2
dic 24
21830
0
sept 24
1362
3
ago 24
2688