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

Python code from XML

By
Andrija Burlic
on 11/3/14, 11:04 AM 937 views

Hi, I have one quick qeustion:

i have this code in python class:

_columns = { 
               'text':fields.char("blabla"),
               }

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?

1

Ludo - Neobis

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

Developer

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.

0

Bole

--Bole--
2385
| 5 4 6
Zagreb | Karlovac, Croatia
--Bole--

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

Bole
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.. 

or,

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 : )
 

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: 11/3/14, 11:04 AM
Seen: 937 times
Last updated: 3/16/15, 8:10 AM