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

Prepopulate fields in a form

By
Mandeep
on 10/17/14, 1:40 AM 879 views

Q1) Is there a way to prepopulate a many2one field when a new object is being created. e.g. Attributes of a product may be pre-defined. Whenever the user opens a form to create a product, some of those attributes are added by default. 

Q2) Is there a way to pre-set some fields of an object (without setting them as default values in the model) while opening a form. e.g. if i want to create multiple types of product through multiple menu actions. I want different forms for these menu actions to have different values of product type preset.

0

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

deep
On 10/17/14, 3:23 AM

To pre-set the values for fields in the New Form, then there are two ways of doing it...

1. Using defaults in .py model

2. In XML., using context passed from action...

So for your criteria, (Q2), since you have different forms and different menu actions linked to it, you can easily achieve it by set default values in context...

Here code goes like this....

<record model="ir.actions.act_window" id="ACTION_ID">
         ...
         <field name="context">{'default_type':'out_invoice'}</field>

 

So key word "default_" followed by column and its value, will pre-set the values

 

Thanks. Will Try Q2.

Mandeep
on 10/17/14, 6:01 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

1 follower(s)

Stats

Asked: 10/17/14, 1:40 AM
Seen: 879 times
Last updated: 3/16/15, 8:10 AM