我在res_users和product_category对象之间有一个product_category关系。所以我把它定义为:
class ResPartner(models.Model):
_inherit = 'res.partner'
category_ids = fields.Many2many('product.category', 'category_user_rel', 'pcu_user_id', 'pcu_category_id', string='Assign To Product Categories')
class ProductCategory(models.Model):
_inherit = 'product.category'
user_ids = fields.Many2many('res.users', 'category_user_rel', 'pcu_category_id', 'pcu_user_id', string='Assign To Users')现在,我想以编程的方式获得当前用户的所有类别及其子类别ids的列表?
谢谢。
发布于 2020-05-15 22:42:08
可以使用与当前用户相关的合作伙伴获取当前用户category_ids:
partner_categories = self.env.user.partner_id.category_ids使用child_of运算符检索所有子类别:
self.env['product.category'].search([('id', 'child_of', partner_categories.ids)])https://stackoverflow.com/questions/61795020
复制相似问题