覆盖Many2many添加项目按钮。 Odoo

时间:2022-12-05 20:24:21

My question would be can I call Add an item button which appears bellow many2many field and give that functionality to my custom button. The result would be something like this: I have a simple primary button and invisible many2many field. When i click my primary button i get to fill my many2many field which still has to stay invisible. Basically primary button has to open form that would be opened by add an items button.

我的问题是我可以调用添加项目按钮,该按钮出现在many2many字段下方,并将该功能提供给我的自定义按钮。结果将是这样的:我有一个简单的主按钮和不可见的many2many字段。当我点击我的主要按钮时,我会填充我的many2many字段,但仍然必须保持隐身状态。基本上主要按钮必须打开表单,通过添加项目按钮打开。

Thank you for considering my question I hope it was clear :) !

感谢您考虑我的问题,我希望很清楚:)!

1 个解决方案

#1


1  

You can always try it with a "wizard" resp. transient model as intermediate to fill the many2many field.

您可以随时使用“向导”进行尝试。瞬态模型作为填充many2many领域的中间体。

So you will have to call the form of that wizard, which should hold your records ID either in context or as field, because you will later write on it to fill the many2many. And ofcourse you need a many2many on this wizard, which will be filled by the user and which content will be written to the record you called the wizard from.

因此,您必须调用该向导的形式,该向导应该在上下文或字段中保存您的记录ID,因为您稍后会在其上写入以填充many2many。当然,在这个向导上你需要一个很多的东西,它将由用户填充,哪些内容将被写入你从中调用的向导。


Another alternative is to look into the js code of odoo and to find the functionality of the select and add buttons. You can then try to define another type of button or just try to get the functionality out of js to python (your button method).

另一种方法是查看odoo的js代码并找到select和add按钮的功能。然后,您可以尝试定义另一种类型的按钮,或者只是尝试将js中的功能变为python(您的按钮方法)。

#1


1  

You can always try it with a "wizard" resp. transient model as intermediate to fill the many2many field.

您可以随时使用“向导”进行尝试。瞬态模型作为填充many2many领域的中间体。

So you will have to call the form of that wizard, which should hold your records ID either in context or as field, because you will later write on it to fill the many2many. And ofcourse you need a many2many on this wizard, which will be filled by the user and which content will be written to the record you called the wizard from.

因此,您必须调用该向导的形式,该向导应该在上下文或字段中保存您的记录ID,因为您稍后会在其上写入以填充many2many。当然,在这个向导上你需要一个很多的东西,它将由用户填充,哪些内容将被写入你从中调用的向导。


Another alternative is to look into the js code of odoo and to find the functionality of the select and add buttons. You can then try to define another type of button or just try to get the functionality out of js to python (your button method).

另一种方法是查看odoo的js代码并找到select和add按钮的功能。然后,您可以尝试定义另一种类型的按钮,或者只是尝试将js中的功能变为python(您的按钮方法)。