Odoo Help


how to change default digits of precision?

on 7/24/13, 4:45 AM 4,937 views
from openerp.osv import osv, fields

import openerp.addons.decimal_precision as dp

class mrp_bom(osv.osv): _inherit = 'mrp.bom' _columns = {

    'cost_price': fields.related('product_id','cost_price',type='float',**digits_compute = dp.get_precision('Product Price')**,relation="product.product", string="Cost Parts Of Bom", store=False),

I want to inherit ‘mrp.bom' to add a field,but i can not change default digits of precision, How can i do that?

Thierry Godin
On 7/24/13, 5:01 AM

Hi , you can change decimal precision by going to :

Configuration / Technical / DB Structure/ Decimal precision

Best regards

Edit : You may take a look at point_of_sale/static/src/js/widget_base.js around line 20

build_currency_template: function(){

            if(this.pos && this.pos.get('currency')){
                this.currency = this.pos.get('currency');
                this.currency = {symbol: '$', position: 'after', rounding: 0.01};

            var decimals = Math.max(0,Math.ceil(Math.log(1.0 / this.currency.rounding) / Math.log(10)));

            this.format_currency = function(amount){
                if(typeof amount === 'number'){
                    amount = Math.round(amount*100)/100;
                    amount = amount.toFixed(decimals);
                if(this.currency.position === 'after'){
                    return amount + ' ' + this.currency.symbol;
                    return this.currency.symbol + ' ' + amount;


You can change the decimal value here :

this.currency = {symbol: '$', position: 'after', rounding: 0.01};

format_currency() is the function called in pos.xml to display prices.

<t t-name="ProductWidget">
        <li class='product'>
            <a href="#">
                <div class="product-img">
                    <img src='' /> <!-- the product thumbnail -->
                    <t t-if="!widget.model.get('to_weight')">
                        <span class="price-tag">
                            <t t-esc="widget.format_currency(widget.model.get('price'))"/>   
                    <t t-if="widget.model.get('to_weight')">
                        <span class="price-tag">
                            <t t-esc="widget.format_currency(widget.model.get('price'))+'/Kg'"/>
                <div class="product-name">
                    <t t-esc="widget.model.get('name')"/>

Maybe you have to reload OpenERP

I have changed the 'Product Price' digits to 4,but here inherit cost_price still is 2.

on 7/24/13, 5:55 AM

Just for let you know that I have updated my answer.

Thierry Godin
on 7/25/13, 7:24 AM

Thank you very much! It is very hard to me.whatever I will try.

on 7/25/13, 11:52 PM

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 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.


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

0 follower(s)


Asked: 7/24/13, 4:45 AM
Seen: 4937 times
Last updated: 3/16/15, 8:10 AM