This question has been flagged
1 Reply
4414 Views

Hi,

I wounder if it is possible to have the button create in tree and form of Supplier Invoices, but not in Customer Invoices?

I removed but it disappear from both, every change that I make I always affect both...

To remove I have this code in addons/my_module/account_view.xml:

      <record id="invoice_tree_inherit" model="ir.ui.view">
        <field name="name">account.invoice.tree.inherit</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="account.invoice_tree"/>
        <field name="arch" type="xml"> 
            <xpath expr='//tree[@string="Invoice"]' position='attributes'>
        <attribute name="create">false</attribute>    
    </xpath>
        </field>
    </record>      


    <record id="invoice_form_change" model="ir.ui.view">
        <field name="name">account.invoice.form.change</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="account.invoice_form"/>
        <field name="priority">1000</field>
        <field name="arch" type="xml">
            <xpath expr='//form[@string="Invoice"]' position='attributes'>
        <attribute name="create">false</attribute>
        <!--<attribute name="edit">false</attribute>-->
    </xpath>
              .......SEVERAL OTHER CHANGES......
        </field>
    </record>

To have the button create just in Supplier Invoices I'va tryed like this:

<record id="invoice_tree_inherit_supplier" model="ir.ui.view">
        <field name="name">account.invoice.tree.inherit</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="invoice_tree_inherit"/>
        <field name="arch" type="xml"> 
            <xpath expr='//tree[@string="Invoice"]' position='attributes'>
        <attribute name="create">true</attribute>    
    </xpath>
        </field>
    </record>    

<record id="action_invoice_tree_supplier" model="ir.actions.act_window.view">
        <field eval="1" name="sequence"/>
        <field name="view_mode">tree</field>
        <field name="view_id" ref="invoice_tree_inherit_supplier"/>
        <field name="act_window_id" ref="account.action_invoice_tree2"/>
    </record>

I notice that the last change that I make is the change that both have.... I can't change just one ...

Avatar
Discard
Best Answer

Hi,

You need create a new view and after this create a action that have a reference for view that you have created. Something like this:

<record id="action_invoice_supplier" model="ir.actions.act_window.view">
        <field eval="2" name="sequence"/>
        <field name="view_mode">tree</field>
        <field name="view_id" ref="invoice_supplier_tree"/>
        <field name="act_window_id" ref="account.action_invoice_tree2"/>   
</record>

I hope this helps.

Avatar
Discard