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 add set default value from tree view edition

By
Victor Godayer
on 3/4/15, 12:33 PM 2,680 views

Hi,

 

In the tree view, I can 'Add an item' that pops up the window of the related object I want to create.

How can i set a default value for a field in the window opened for this related object using data from the former object ?

I don't know if I am clear enough...

 

Thanks for your help !

1

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 3/5/15, 5:09 AM

If am not wrong, you are trying to set data from former object to New object... So in your case it should be parent and child objects...

If yes, then you can set in 2 ways...

1. Context : In XML by using context you set the value, or access the context value in your Child Object defaults method in Py Class..

2. Parent: In XML, by using the parent keyword also you can set value of its  parent data...

(Ex. <field name="O2M_lines" context={'default_CHILD_FIELD' : parent.PARENT_FIELD })
 

Tips: use Ctrl + H, if you are using studio, to perform search action in the entire standard addons module for more examples

Thank you I manage to work it out with your explanation. Last question : is it possible to concatenate such as : context="{'default_CHILD_FIELD' : '%s -%s'%(parent.PARENT_FIELD1,parent.PARENT_FIELD2) }" ?

Victor Godayer
on 3/5/15, 12:12 PM
1
Alby Antony
On 3/5/15, 3:40 AM

you can use database constrain as well.. if i want to set default value for one of the field in table then class claim(osv.osv): _name = "test" _description = "test" _columns = { 'claimed_amount':fields.integer('Amount claimed'),} _defaults = { 'claimed_amount': '1000', }

 

 

 

1

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 3/5/15, 12:36 AM

Hi,

You can set default value for any of field from selected form view. Just see the below screen. User can set default value from "debug" mode.

second way to manage default value of any model from python code is that we can define _defaults = {} into that model from .py file.

I hope this will help you.

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: 3/4/15, 12:33 PM
Seen: 2680 times
Last updated: 3/16/15, 8:10 AM