Odoo Help

3

1
12 Answers
2
Avatar

René Schuster Germany

--René Schuster--
1778
| 7 7 10
Weinheim, Germany
--René Schuster--

Challenge Everything!

René Schuster Germany
11/28/13, 6:00 AM

The Solution might be class="oe_edit_only".

<field name="yourfield" class="oe_edit_only"/>

This will hide the field, when view is in view mode. oe_edit_only also works for other design elements like labels, groups, etc..

1 Comment
René Schuster Germany
12/17/13, 6:48 AM

To achieve the opposite (hide in edit mode), the answer to this question is very helpful and works fine for me:

http://help.openerp.com/question/11853/inverse-of-css-class-oe_edit_only/

1
Avatar

Parth Gajjar India

--Parth Gajjar--

3585
| 4 4 7
Gandhinagar, India
--Parth Gajjar--


Parth Gajjar India
3/21/13, 2:58 AM

First thing i can not understand well what you want to do but i try to do what i understood.

I add attrs field in sale order lines like this

<field name="discount" attrs="{'invisible':[('price_unit','=',0)]}" groups="sale.group_discount_per_so_line"/>

This means my discount field become invisible if price_unit = 0 And that's working See in image

image description

And if you wish user can see the field but can't edit then better use readonly attribute

Hope this will help you

8 Comments
HIGHCO - Nicolas Clavier France
3/21/13, 5:54 AM

Hey Parth, Thanks for your answer, my goal is the following: in a listview child of a form view (one2many widget) I have one fields.text that holds a lot of text. Since there is no option to truncate the text shown when the whole form is in view mode, I did as advised in another post. I created a fields.function that returns a truncated version of my fields.text. Now, I want to have the fields.text to be visible in the listview when the form is in edit mode only, and the fields.function (truncated text) to be visible when the form is in view mode.

HIGHCO - Nicolas Clavier France
3/21/13, 6:08 AM

in the previous post mentionned in my question, someone advised setting the invisble attribute with invisible="context.get('set_editable',False)" but I found out that the set_editable key is not in the context. Therefore I want to clarify within this post : is there a way to find out in what state (edit|view) a form is at all ?

Parth Gajjar India
3/21/13, 8:42 AM

Means you want to enable and disable whole column during switching between edit and saved mode .... I don't know about Is there a way to find out in what state (edit|view) a form is at all ?

But one other thing is pass class="oe_edit_only" this will disable field in saved mode and display that field in edit mode. but i never try that on one2many. Try it and see what happen

HIGHCO - Nicolas Clavier France
3/21/13, 10:55 AM

that was a good track at first but so far it has no effect. Though the css trick should be investigated. I actually tried it on a label and it didn't affect visibility, even though the class was on the dom element.

HIGHCO - Nicolas Clavier France
3/21/13, 11:00 AM

correction : it does work on a label, I had initially tested on a validated sale.order that could not be edited anymore, therefore not in edit mode. But on a draft sale.order it worked on a label. It still doesn't work on a table column though.

Parth Gajjar India
3/22/13, 9:48 AM

Then there are 2 options .........

First made own widget(this is hard) .......

Second easiest way is use Jquery And JavaScript

For Local Jquery and javascript See this link Local CSS,JQuery and javascript in Openerp

HIGHCO - Nicolas Clavier France
3/22/13, 12:14 PM

ok, so no easy way then. Thanks for the help anw !

HIGHCO - Nicolas Clavier France
3/26/13, 11:55 AM

Back to this topic, I looked through the CSS but didn't spot a class that does the opposite like class="oe_browse_only" ... any hint ?

0
Dr Obx United Kingdom
6/18/15, 11:17 AM

Even a couple of years later I found it very useful. It still can help :)

Currently added an image which is overlapping product avatar but while editing record I couldn't add/change avatar because product avatar was covered by the image i added :)

So I was needed something to solve this issue. Right  after I added this class="oe_edit_only" overlapping image gets hidden so i can add/change product's avatar now :)


in edit mode:

in view mode:

"in stock"

in view mode:

"out of stock"


Thank you guys :)

2 Comments
Atte Isopuro Finland
7/27/15, 9:37 AM

I'd love to see some example code of this Dr Obx!

Dr Obx United Kingdom
7/27/15, 10:50 AM
What do you mean ?
Example of what ?

On 27 July 2015 at 15:37, Atte Isopuro <atte.isopuro@web-veistamo.fi> wrote:

I'd love to see some example code of this Dr Obx!

--
Atte Isopuro
Sent by Odoo S.A. using Odoo about Forum Post False

Ask a Question
Keep Informed
2 follower(s)
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.

Register
Odoo Training Center

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

Test it now