我正在使用 Odoo 10-e。我为订单创建了一个自定义类
class Order(models.Model):
_name = 'amgl.order'
_description = 'Use this class to maintain all transaction in system.'
name = fields.Char(string='Name',readonly=True)
order_line = fields.One2many('amgl.order_line', 'order_id', string='Order Lines')
total_qty = fields.Float(string='Total Expected')
total_received_qty = fields.Float(string='Total Received Quantity')
customer_id = fields.Many2one('amgl.customer', string='Customers', required=True)
is_pending = fields.Boolean()
date_opened = fields.Datetime('Date Opened', required=True)
date_received = fields.Datetime('Date Received')
我还为此类创建了一个 View ,它在 TreeView 中显示所有记录。现在我想创建另一个名为“待处理订单”的 View ,其中我想显示 is_pending
为 true 的所有订单。我是新人,也许这就是为什么我无法在 Odoo 代码库中找到任何示例的原因。
最佳答案
为此,您不需要创建新 View ,只需创建新菜单和操作并使用域过滤记录。
<record id="action2_...." model="ir.actions.act_window" >
<field name="name"> Action Title </field>
....same as the first action...
<field name="res_model">your.model</fiel>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('is_pending', '=', True)] </field>
</record>
<menuitem ..... action="action2_.." />
注意:操作可以具有诸如 domain
、context
、view_id
、search_view_id
、view_ids 等属性
...等等,最好的学习方法是阅读它们并查看 odoo 中的代码。
关于Odoo-如何使用一个类添加多个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45042730/