Python 使用odoo中的同一字段添加多个条目

Python 使用odoo中的同一字段添加多个条目,python,odoo,odoo-12,Python,Odoo,Odoo 12,我有一个名为items的字段,我将其定义为多个字段 item_ids = fields.Many2many('ics.itemdetails',string="Add items") 模型ics.itemdetails具有以下字段 itm_nams = fields.Many2one('product.template',string="Name") weight = fields.Char(string="Weight") 我希望用户从product.template条目中选择一个产品,并

我有一个名为items的字段,我将其定义为多个字段

item_ids = fields.Many2many('ics.itemdetails',string="Add items")
模型ics.itemdetails具有以下字段

itm_nams = fields.Many2one('product.template',string="Name")
weight = fields.Char(string="Weight")

我希望用户从product.template条目中选择一个产品,并为他们添加的每个产品填写另一个字段。另外,第二个用户无法从以前的条目中选择条目。问题是第二个用户可以选择以前输入的条目。我这样做对吗?如何防止为第二个用户显示以前的条目?。我正在使用odoo 12。

您可以使用ir.rule设置对记录的访问


用户可以查看自己的记录

您的意思是,如果产品是由user1选择的,则user2无法选择它?@TerrencePoe user1和user2可以从product.template中选择相同的项目。user1的条目(包括itemdetails)无法被user2看到。您需要的是一个而不是多个。@EasyOdoo,Oops!。。就这么简单!。。用户id是否应该是itemdetails模型中的字段?将
ref=“model\u name”
设置为要设置规则的模型。