Odoo Help

0

How to define additionnaly decimal precision for a new field

By
Mind And Go
on 10/31/14, 12:23 PM 3,174 views

Hy,

I would like to know how to add decimal precision for a specific field. I know thate there are already some values : http://localhost:8072/web?debug=#page=0&limit=80&view_type=list&model=decimal.precision&menu_id=90&action=81

And now, how to add a behaviour for a new field?

regards

2

Hi,

If you want to put new decimal precision for the field of your custom module then you have to do following things.

1) Create new record of decimal precision using xml file as like below.

        <record forcecreate="True" id="decimal_custom_dp1" model="decimal.precision">
            <field name="name">Custom1</field>
            <field name="digits">4</field>
        </record>

2) Then you can use your newly define decimal precision in you custom field as like below.

import openerp.addons.decimal_precision as dp

. . . .

'custom_field1': fields.float(string='Custom Field', digits_compute=dp.get_precision('Custom1') )

Now, you can see the decimal precision of 'custom_field1' according to set new decimal precision 'Custom1'. I hope it is helpful to you.

 

A great thanks, I wil try this ASAP

Mind & Go, Mind And Go
on 11/2/14, 7:08 AM

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

Question tools

2 follower(s)

Stats

Asked: 10/31/14, 12:23 PM
Seen: 3174 times
Last updated: 3/16/15, 8:10 AM