Odoo Help


Python code from XML

Andrija Burlic
on 11/3/14, 11:04 AM 1,633 views

Hi, I have one quick qeustion:

i have this code in python class:

_columns = { 

value= 'text'


and this one i XML file:

<field name="{value}"/>


Of course, I want to show text , so I have to tell OpenERP to read Python variable 'value' as variable, not as constant text. 

How to do this?


Ludo - Neobis

--Ludo - Neobis--
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--


Ludo - Neobis
On 11/3/14, 11:38 AM

Create a field for it and provide the field with a default value.

The (old) API of OpenERP (not based on model.Models) does not care about abything outside of the pre-set keywords to look for. It will look for things like _columns, _name etc. but will not use your "value" property.




| 5 4 6
Zagreb | Karlovac, Croatia

there is only 10 kind of people the ones that understand binary ... and others

On 11/4/14, 3:52 AM

Not realy clear what you want to do... .
but based on your question there is few possible solutions:

1. you want some default value for the field... in that case:
_columns = { 'field_name':fields.text('Field_label') }  #define field in your model..
_defaults = { 'field_name' : 'Some default field value' } # will insert that default value upon creting new record in your model.. 


2. for defined field you wand to show a hint what kind of value you expect in that field , Ž
but no default value is entered... then.. _columns is the same, 
and in xml defining view for that field put:

<field name='field_name' placeholder="Some hint text' />
<!-- this will show hint in field, but that is greyed out, and it is only visible until some value is entered in field -->


hope it helps,

may the source be with you : )

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/3/14, 11:04 AM
Seen: 1633 times
Last updated: 3/16/15, 8:10 AM