Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
7516 Widoki


Hi .
I want to create a view to move fields in sale view .
I have plenty of modules which modify the product view in sales.
I would like my custom view will be all the time the last to modify the product view is it possible?

For example i want to hide a page (variants) but when i do that : 


<record id="product_template_inherited_variants_repalce_form2" model="ir.ui.view">
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page[@name='variants']" position="replace"/>
</field>
</record>

A module after need this page to add things so i have an error : 

ValueError: Element '<field name="attribute_line_ids">' cannot be located in parent view

So the best thing is to be the last for modifying this view. Is it possible to define that? 
I can t inherit of all module , because i will add new modules soon for sure :( 

Thanks a lot for your answer


Awatar
Odrzuć
Autor

Perfect Paresh it works.

Thanks a lot !

Great. Please click the check mark next to the answer to mark it as resolved.

Najlepsza odpowiedź

Hi Thomas:

You can define an attribute called "priority" in the view definition to control the sequence in which the views are applied. The default priority is set at 16. Try setting it to 100 so your custom view definition is applied after all the other views. To expand on your example, try this.

<record id="product_template_inherited_variants_repalce_form2" model="ir.ui.view">
<field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_only_form_view"/>
    <field name="priority">100</field>
    <field name="arch" type="xml">
<xpath expr="//notebook/page[@name='variants']" position="replace"/>
</field>
</record>
Awatar
Odrzuć
Autor Najlepsza odpowiedź

Thanks ​Rajkumar Murugan
Yes i can do this , but infact my question is more general.
Is it possible to say : This view is the last inherit of an inital view.
I want all modules do things in the inital view before my view ​
Is it possible?
Like to define a sequence of something like that? :)

Thnaks a lot

Awatar
Odrzuć
Najlepsza odpowiedź

Hi thomas,

If you want to hide a page variants, you have to use position as attributes. For eg. see below code

<record id="product_template_inherited_variants_repalce_form2" model="ir.ui.view">
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_only_form_view"/>
    <field name="arch" type="xml">
        <xpath expr="//notebook/page[@name='variants']" position="attributes"/>
            <attribute name="invisible">0</attribute>
    </field>
</record>

For further information about view inheritance, click this link 

http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lis 18
5429
1
lis 24
1577
5
lip 24
92809
1
gru 23
3000
2
mar 23
2244