Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to restrict modifying sale module view after inheriting into custom module?

By
savita
on 9/22/16, 2:11 AM 139 views

Hi All,

I have created a custom module called test and inherited sale.order and added some fields in that.. and in __openerp__.py manifest file i have called sale dependence..
When I install module I got my test module with all fields defined. But if I see sales module.. original sale view has been modified.
How to do. Like it should not affect original sale module and I changes should reflect in my custom test module.

Example:

test.py

class Test(models.Model):
    _inherit = "sale.order"  
    _description = "Test"
   vin_no = fields.Char(string='VIN No', required=True, size=13)   
regn_no = fields.Char(string='Regn No')

test.xml

<record id="view_order_form_inherite" model="ir.ui.view">            
    <field name="name">Test</field>           
    <field name="model">sale.order</field>                                
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
        <field name="regn_no" placeholder="Registration No" required="1"/>                   
        <field name="vin_no" placeholder="VIN No"/>
    </field>
  </record>

Still making simply here we have added two custom fields vin_no and reg_no in our custom module by inheriting sale.order so we want these two fields to add only in custom module not in sale base module. But its modifying in sale form view too..So we want to restrict this...Kindly people can post any method available to restrict this kind of issue?


Suggestions will be appreciated..

0

Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
2983
| 3 2 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 9/22/16, 3:28 AM

You can use the mode primary in the declaration.

That will create a new view with your changes the inherited, instead of added your change in the inherited view.


<record id="view_order_form_inherite" model="ir.ui.view">
                <field name="name">Test</field>
                <field name="model">sale.order</field>
<field name="mode">primary</field>
                <field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
        <field name="regn_no" placeholder="Registration No" required="1"/>
                       <field name="vin_no" placeholder="VIN No"/>
    </field>
</record>
 

Hi Jérémy Kersten,

I have added primary into my custom module but it does not work..base sale view is modifying according to my custom module.

Thanks

savita
on 9/22/16, 5:00 AM

Did you checked in the backend that the view is well setted as "primary" with your upgrade ?

Jérémy Kersten (jke)
on 9/22/16, 5:05 AM

Yes i have checked but its giving same view.

savita
on 9/23/16, 12:58 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 9/22/16, 2:11 AM
Seen: 139 times
Last updated: 9/22/16, 3:30 AM