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 can I change the look of an field in the products tree view?

By
Stefan Reisich
on 3/1/13, 10:10 AM 1,153 views

I have created a new field special_price in products view. Now I want create a module that changes the look of the product tree view so that the price column looks like this: 119,00 100,00 (normal price special price). But only if the product has a special price.

How can I do that?

Thank you very much.

1

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--
4136
| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 3/2/13, 8:47 AM

Hi,

see first this url (sorry I not enough Karma to add complete url :( ):

h t t p : / / en.wikipedia.org/wiki/Strikethrough

to test :

create a new field type char normal_price_char with same string than normal_price ((to display the same name in view).

add it to the tree view and do invisible field normal_price in this same tree view.

in the form view, for fields normal_price and extra_price add the same attribute on_change function named by example onchange_normal_price_char with in body function this 2 fields.

in python class create the onchange function onchange_normal_price_char.

in onchange function, add test: if extra_price:

normal_price_char_temp = str(normal_price) (convert integer to string)

add in this condition a function which custom normal_price_char_temp with character "-" betweeen each char number (example : 1234 become 1-2-3-4).

use function attribute encode() with unicode U+0336 normal_price_char = normal_price_char_temp.encode('U+0336') (I hope this unicode will be known else search how to write this unicode correctly if this doesn't work)

else: normal_price_char = str(normal_price)

return {'value'{normal_price_char ': normal_price_char}}

perhaps you should do some personnal customs...

Hope this will help and work.

Don't forget to post your module to the openerp apps if it works ;)

Bye

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/1/13, 10:10 AM
Seen: 1153 times
Last updated: 3/16/15, 8:10 AM