Skip to Content
Menu
This question has been flagged
1 Reply
18498 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?

Avatar
Discard
Best Answer

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');
            }else{
                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;
                }else{
                    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'))"/>   
                        </span>
                    </t>
                    <t t-if="widget.model.get('to_weight')">
                        <span class="price-tag">
                            <t t-esc="widget.format_currency(widget.model.get('price'))+'/Kg'"/>
                        </span>
                    </t>
                </div>
                <div class="product-name">
                    <t t-esc="widget.model.get('name')"/>
                </div>
            </a>
        </li>
    </t>

Maybe you have to reload OpenERP

Avatar
Discard
Author

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

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

Author

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

Related Posts Replies Views Activity
17
Dec 21
22539
1
Jul 15
6183
2
Mar 15
7780
2
Mar 15
4643
2
Mar 15
9871