we try to show a special list view of sale_order_lines within a popup.
i tried to add "search" to view_mode but without success. Also adding search_view_id seems not to work. The list will be shown in wizard-popup but without any search/filter fields.
how can i achieve that also the search field and filter options are visible on top of this inline PopUp:
ir_model_data = self.env['ir.model.data']
try:
tree_id = ir_model_data.get_object_reference('sale', 'view_order_line_tree')
form_id = ir_model_data.get_object_reference('sale', 'sale_order_line_view_form_readonly')
search_id = ir_model_data.get_object_reference('sale', 'view_sales_order_line_filter')
tree_id = tree_id[1] if tree_id else False
form_id = form_id[1] if form_id else False
search_id = search_id[1] if search_id else False
except ValueError:
view_id = False
res = { # Dictionary für View-Parameter
'type': 'ir.actions.act_window',
'name': ('Test'),
'res_model': 'sale.order.line',
'view_type': 'form',
'view_mode': 'tree,search, form',
'view_id': False,
'search_view_id': search_id,
'target': 'new',
'domain': [('order_partner_id','=',self.id),('state','!=','draft'),('state','!=','cancel'),('state','!=','sent')],
'views': [(tree_id, 'tree'), (search_id, 'search') , (form_id, 'form')],
}
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
@Hilar AK: regarding to your answer i trief the following (mostly copied from oribinal sale_views.xml:
<record id="x_view_order_line_tree" model="ir.ui.view">
<field name="name">sale.order.line.tree</field>
<field name="model">sale.order.line</field>
<field name="arch" type="xml">
<tree string="Sales Order Lines" create="false">
<field name="order_id"/>
<field name="order_partner_id"/>
<field name="name"/>
<field name="salesman_id"/>
<field name="product_uom_qty" string="Qty"/>
<field name="qty_delivered"/>
<field name="qty_invoiced"/>
<field name="qty_to_invoice"/>
<field name="product_uom" string="Unit of Measure" groups="uom.group_uom"/>
<field name="price_subtotal" sum="Total" widget="monetary"/>
</tree>
</field>
</record>
<record id="x_sale_order_line_view_form_readonly" model="ir.ui.view">
<field name="name">sale.order.line.form.readonly</field>
<field name="model">sale.order.line</field>
<field name="arch" type="xml">
<form string="Sales Order Item">
<sheet>
<div class="oe_title">
<h1>
<field name="display_name" readonly="1"/>
</h1>
</div>
<group>
<group>
<field name="order_id" readonly="1"/>
<field name="product_id" readonly="1"/>
<field name="name" readonly="1"/>
<field name="product_uom_qty" readonly="1"/>
<field name="qty_delivered" readonly="1"/>
<field name="qty_invoiced"/>
<field name="product_uom" readonly="1"/>
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
<field name="order_partner_id" invisible="1"/>
<field name="display_type" invisible="1"/>
<field name="product_updatable" invisible="1"/>
</group>
<group>
<field name="price_unit" readonly="1"/>
<field name="discount" groups="sale.group_discount_per_so_line" readonly="1"/>
<field name="price_subtotal" widget="monetary"/>
<field name="tax_id" widget="many2many_tags" readonly="1"/>
<field name="price_tax" widget="monetary"/>
<field name="price_total" widget="monetary"/>
<field name="currency_id" invisible="1"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="x_view_sales_order_line_filter" model="ir.ui.view">
<field name="name">sale.order.line.select</field>
<field name="model">sale.order.line</field>
<field name="arch" type="xml">
<search string="Search Sales Order">
<filter string="To Invoice" name="to_invoice" domain="[('qty_to_invoice','!=', 0)]" help="Sales Order Lines ready to be invoiced"/>
<separator/>
<filter string="My Sales Order Lines" name="my_sales_order_lines" domain="[('salesman_id','=',uid)]" help="Sales Order Lines related to a Sales Order of mine"/>
<field name="order_id"/>
<field name="order_partner_id" operator="child_of"/>
<field name="product_id"/>
<field name="salesman_id"/>
<group expand="0" string="Group By">
<filter string="Product" name="product" domain="[]" context="{'group_by':'product_id'}"/>
<filter string="Order" name="order" domain="[]" context="{'group_by':'order_id'}"/>
<filter string="Salesperson" name="salesperson" domain="[]" context="{'group_by':'salesman_id'}"/>
</group>
</search>
</field>
</record>
<record id="x_action_sale_lines_custom" model="ir.actions.act_window">
<field name="name">Sales Order Lines</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.order.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="x_article.x_view_sales_order_line_filter"/>
<field name="domain"></field>
<field name="context">{
'search_default_team_id': [active_id],
}
</field>
</record>
<record id="x_sale_order_action_view_order_tree" model="ir.actions.act_window.view">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="x_article.x_view_order_line_tree"/>
<field name="act_window_id" ref="x_action_sale_lines_custom"/>
</record>
But what should i return in python code now?
You need to define your action as XML in views file and need to bind your views with actions. Then after fetch the actions data from your custom functions and return as like you done.
This is the format of binding new actions with views.
eg:
<record id="action_auto_backup_odoo_config_view_form_bind" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="view_auto_backup_config_form"/>
<field name="act_window_id" ref="action_auto_backup_odoo_config"/>
</record>
Here act_window_id should be your action ID.
can you give some more information how to change this regarding my example?
can you give a working example? i still does not work. i do not get any search bar or search possibility in popup list/tree views.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up