Em muốn set default cho group by thì làm sao ạ
0
1 Trả lời
Best Answer
Bạn truyền 'search_default_ten_group_by':1 vào context của action tương ứng.
Dưới đây là ví dụ trong module fleet của Odoo 12. Định nghĩa search view với group by có tên là `groupby_vehicle`, ở context của action `fleet_vehicle_log_fuel_action` thì gọi group đó ra bằng {"search_default_groupby_vehicle" : True}
<record id='fleet_vehicle_log_fuel_view_search' model='ir.ui.view'> <field name="name">fleet.vehicle.log.fuel.search</field> <field name="model">fleet.vehicle.log.fuel</field> <field name="arch" type="xml"> <search string="Vehicles Fuel Logs" > <field name="vehicle_id" /> <field name="date"/> <field name="purchaser_id" /> <field name="liter" /> <field name="amount" sum="Price"/> <group expand="0" string="Group By"> <filter name="groupby_vehicle" context="{'group_by' : 'vehicle_id'}" string="Vehicle"/> </group> </search> </field> </record> <record id='fleet_vehicle_log_fuel_action' model='ir.actions.act_window'> <field name="name">Vehicles Fuel Logs</field> <field name="res_model">fleet.vehicle.log.fuel</field> <field name="view_type">form</field> <field name="view_mode">tree,kanban,form,graph</field> <field name="context">{"search_default_groupby_vehicle" : True}</field> <field name="help" type="html"> <p class="o_view_nocontent_smiling_face"> Create a new fuel log </p><p> Here you can add refuelling entries for all vehicles. </p> </field> </record>