Skip to Content
Menu
This question has been flagged

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
Discard
Best Answer

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
Discard
Author

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

Related Posts Replies Views Activity
0
Jun 23
1033
0
Sep 17
3220
0
Sep 24
122
3
Aug 24
527
0
Feb 24
263