两者之间的关系是什么res.合伙人以及资源用户在奥多13?

2024-05-20 22:44:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我在odoo12工作,每当我想区分合作伙伴用户时,我使用以下代码

is_customer = False/True    
self.env['res.partner'].search([('customer', '=', is_customer)])

但是现在他们已经离开了。 我想要一个建议,如何像上面那样区分它们? 有一个领域不适合我。在


Tags: 代码用户selfenvfalsetruesearchpartner
3条回答

res.usermany2one字段res.partner命名为partner_id,您可以像这样提取用户的所有合作伙伴:

   # this will extract every partner that is related to user
   partner_users = self.env['res.users'].search([]).mapped('partner_id')  

如果要使用其他字段(如name)筛选合作伙伴:

^{pr2}$

比较或者使用customer字段对您来说更像是一种巧合,因为您的Odoo中没有customersupplier不是用户的合作伙伴。在

但是你真的应该用user_ids来代替,对于每一个像odoo8的版本。因为这是一个使用res.userspartner_id字段作为关系的one2many字段,它应该始终有效。在

您可以在base: Remove customer/supplier fields on res.partner提交消息中找到详细的解释和示例。在

摘录

This commit allows to call name_search with context key res_partner_search_mode that can take currently two values: "customer" or "supplier".

When ordering search results, order partners by the number of SO they have when the value is "customer" and by the number of PO if the value is "supplier".

Top suppliers/customers are displayed above in a PO/SO partner dropdown.

We have thought about different implementations before selecting this one

相关问题 更多 >