Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
17135 Lượt xem

I'm scratching my head to find a way to change the default filter of the customer view et eventually other views too.

My filter is created, but I just don't know how to change the actual default filter to "Customer + My Filter"... I want to inherit this windows action to add my extra search_default. Is it possible???

        <record id="action_partner_form" model="ir.actions.act_window">
            <field name="name">Customers</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner</field>
            <field name="view_type">form</field>
            <field name="view_mode">kanban,tree,form</field>
            <field name="context">{"search_default_customer":1}</field>
            <field name="search_view_id" ref="view_res_partner_filter"/>
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                Click to add a contact in your address book.
              </p><p>
                Odoo helps you easily track all activities related to
                a customer; discussions, history of business opportunities,
                documents, etc.
              </p>
            </field>
        </record>

Ảnh đại diện
Huỷ bỏ

Hope these customization tips will help you: https://learnopenerp.blogspot.com/

Câu trả lời hay nhất

This is working well if you want to add a filter for example

<record id="search_view_record_id" model="ir.ui.view">
        <field name="name">your_view_name</field>
        <field name="model">your.model</field>
        <field name="arch" type="xml">
            <search string="Your string">
                <filter name="field_you_want_to_filter" string="Your string" domain="[]"/>
            </search>
        </field>
 </record>
<record id="module_name.action_you_want_to_override" model="ir.actions.act_window">
        <field name="search_view_id" ref="search_view_record_id"></field>
        <field name="context">{'search_default_field_you_want_to_filter': 1}</field>
 </record>    
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Mathieu,

In order to override the predefined action, you can simply define this action record again in your module, but remember to append original module_name/ action source module_name before action id to override.like:

<record id="[original_module_name].action_partner_form" model="ir.actions.act_window">

keep everything as it is, and just make the changes you want. like for context:

<field name="context">{"search_default_customer":1, [ + your_filter_to_be_added]}</field> 

Hope it helps!    

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Here is what I did precisely. I didn't reference the original module in fact!

<record id="base.action_partner_form" model="ir.actions.act_window"> 
<field name="context">{'search_default_customer':1, 'search_default_my_filter':1}</field> </record>
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 2 25
1019
1
thg 8 24
1354
2
thg 11 24
2247
3
thg 10 23
14074
2
thg 2 23
1873