Skip to Content
Menu
This question has been flagged
3 Replies
8498 Views

Hi all, I have been trying to override the left menu item "Quotations" in the Purchases Module (making domain changes) and am having touble. I copied the code and inherited, but instead of overriding the menu item it creates a new menu item. Is there a way to just override it instead? This is what my code looks like currently:

     

        <record id="purchase_rfq" model="ir.actions.act_window">

            <field name="name">Quotations</field>

            <field name="type">ir.actions.act_window</field>

            <field name="inherit_id" ref="purchase.purchase_order_tree"/>

            <field name="res_model">purchase.order</field>

            <field name="context">{}</field>

            <field name="domain">[('state','in',('draft','sent','confirmed')),('origin','=','')]</field>

            <field name="view_mode">tree,form,graph,calendar</field>

            <field name="search_view_id" ref="purchase.view_purchase_order_filter"/>

            <field name="help" type="html">

              <p class="oe_view_nocontent_create">

                Click to create a request for quotation.

              </p><p>

                The quotation contains the history of the discussion/negociation

                you had with your supplier. Once confirmed, a request for

                quotation is converted into a purchase order.

              </p><p>

                Most propositions of purchase orders are created automatically

                by OpenERP based on inventory needs.

              </p>

            </field>

        </record>

        <menuitem action="purchase_rfq" id="menu_purchase_rfq"

            parent="purchase.menu_procurement_management"

            sequence="1"/>

Avatar
Discard

Thanks Janeesh, your answer was very helpful. I had to change the menuitem action to purchase.purchase_rfq as well - but I understand inheritance in these situations better now.

Best Answer

Hi,

There are two ways to implement this. Either override the action or override the menu.

If overriding the action, then change the id of action to 'purchase.purchase_rfq'. In this case no need to change anything in menu part. In second case, give any id to the action created by you. In this case id seems 'purchase_rfq'. Then in menu you have to write like this.         <menuitem action="purchase_rfq" id="purchase.menu_purchase_rfq"
            parent="menu_procurement_management"
            sequence="0"/>

Avatar
Discard
Best Answer

Hi Alex,

You should override the menu by,

<record id="purchase.purchase_rfq" model="ir.actions.act_window"> 

instead of <record id="purchase_rfq" model="ir.actions.act_window">.

Because when you would create a record, it creates with module reference(Module Name+Existing ID), the new module having same record id will not override the menu.

Moreover if you want to change ONLY the DOMAIN you can only override the domain instead of the whole code. The concern is, whatever you want to override just change that part by inheriting the id. Like,

 <record id="purchase.purchase_rfq" model="ir.actions.act_window">

            <field name="domain">[('state','in',('draft','sent','confirmed')),('origin','=','')]</field>

</record>

Try this. Will work for sure.

Thanks.

Avatar
Discard
Author

This is perfect, thank you. That middle paragraph really helped cement some things for me that have been causing issues lately. One more question if you have a chance - I would like the domain for quotations to be anything that does not have a "Source Document". The worked for me, ('origin','!=',''), but for some reason ('origin','=','') does not pull up any results, even though I have some POs without Source Documents. Is there a better syntax for this? Thanks!

Author

Scratch that, figured it out - ('origin','=', False) worked. Thanks again!

Best Answer

Hi,

There are two ways to implement this. Either override the action or override the menu.

If overriding the action, then change the id of action to 'purchase.purchase_rfq'. In this case no need to change anything in menu part. In second case, give any id to the action created by you. In this case id seems 'purchase_rfq'. Then in menu you have to write like this.         <menuitem action="purchase_rfq" id="purchase.menu_purchase_rfq"
            parent="menu_procurement_management"
            sequence="0"/>

Avatar
Discard