Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Hello my friend;
Please i have a question and i want your help.
In fact, i have two fields with a complicated structure.
* First Field: Its an integer but want when it is displayed to show it with 2caracters and then carriage return.
Example: the number is 254789 when it is displayed it must be showed as 25 then 47 and then 89.
*Second Field: its a char when its is displayed it has to show it with 4caracters and then carriage return.
Example: the char is 'today' when it is displayed it must be showed as toda then y.
Need your help please.
Is here any suggestion.
Thanks a lot in advance.
Dear Drees Far,
Using on change method you can perform your structure.
Step 1: Create two new field which has char data type
Step 2: Now you will put on change method in First Field(integer) and Second Field(char)
Step 3: On change method return the value as per you set logic in python file and set those value in new two char field.
in .XML file
<field name="first_field" on_change="change_first_field(first_field)" />
<field name="second_field" on_change="change_second_field(second_field)" />
in .PY file
First create two new field which have char data type
'new_first_field': fields.char('New First Field'),
'new_second_field': fields.char('New Second Field'),
def change_first_field(self, cr, uid, ids, first_field, context=None):
if not first_field:
new_str = str(first_field)
new_value_first = new_str[0:2] + ' Then ' + new_str[2:4] + ' Then ' + new_str[4:6]
def change_second_field(self, cr, uid, ids, second_field, context=None):
if not second_field:
new_str = str(second_field)
new_value_second = new_str[0:4] + ' Then ' + new_str[4:5]
May this code will help you
Thanks & Regards
Ankit H Gandhi
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
|Asked: 9/30/15, 5:52 AM|
|Seen: 758 times|
|Last updated: 9/30/15, 7:41 AM|