Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
17236 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

 

Ảnh đại diện
Huỷ bỏ
Tác giả

A great thanks, I wil try this ASAP