xml - How to pass variables to a search view in OpenERP7? -
i have created button in res.partner form, calls action.
this action opens tree view of other different model, res.partner.link.category
(with fields partner_id
, link_category_id
, type
, date
, observations
) ---this table relationship between res.partner
, other table called link.category
.---
i created search view res.partner.link.category
too.
what need is: if looking partner, , click on button, see res.partner.link.category
tree view records have partner_id
looking @ moment of click. how can utilize context in case?
how can pass context (with partner_id) search view? tried lot of things not able manage target.
here code of button:
<button name="%(res_partner_extended.action_view_history_res_partner_link_category)d" string="view whole history" type="action" context="{'default_partner_id': active_id}"/>
this action calls:
<record id="action_view_history_res_partner_link_category" model="ir.actions.act_window"> <field name="name">view whole history</field> <field name="type">ir.actions.act_window</field> <field name="res_model">res.partner.link.category</field> <field name="view_type">form</field> <field name="view_mode">tree</field> <field name="context">{'default_partner_id': context.get('default_partner_id', false)}</field> <field name="view_id" ref="res_partner_link_category_history_tree_view" /> <field name="target">current</field> </record>
the tree view:
<record id="res_partner_link_category_history_tree_view" model="ir.ui.view"> <field name="name">res.partner.link.category.history.tree</field> <field name="model">res.partner.link.category</field> <field name="type">tree</field> <field name="arch" type="xml"> <tree string="link categories" create="false"> <field name="partner_id" /> <field name="link_category_id" /> <field name="type" /> <field name="date" /> <field name="observations" /> </tree> </field> </record>
and search view:
<record id="res_partner_link_category_history_search_view" model="ir.ui.view"> <field name="name">res.partner.link.category.history.search</field> <field name="model">res.partner.link.category</field> <field name="type">search</field> <field name="arch" type="xml"> <search> <filter name="partner_id" string="current partner" domain="[('partner_id','=',context.get('default_partner_id', false))]"/> </search> </field> </record>
can help me, please?
try adding domain on action
opend button :
<field name="domain">[('partner_id','=',active_id)]</field>
and if wanna trigger default filter in search in context on button pass value of filter name default set true, trigger default fitelr applied when open window. sample code:
<button name="%(res_partner_extended.action_view_history_res_partner_link_category)d" string="view whole history" type="action" context="{'search_default_partner_id': 1}"/>
hope help.
xml search view openerp openerp-7
No comments:
Post a Comment