[FIX] point_of_sale: use 'Product Price' decimal precision for product prices

This commit is contained in:
Frederic van der Essen 2014-11-11 19:32:52 +01:00
parent d1fb79ad14
commit 95e79c9f6f
4 changed files with 26 additions and 23 deletions

View File

@ -139,6 +139,15 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
ids: function(self){ return [self.user.company_id[0]] },
loaded: function(self,companies){ self.company = companies[0]; },
},{
model: 'decimal.precision',
fields: ['name','digits'],
loaded: function(self,dps){
self.dp = {};
for (var i = 0; i < dps.length; i++) {
self.dp[dps[i].name] = dps[i].digits;
}
},
},{
model: 'product.uom',
fields: [],
domain: null,
@ -795,12 +804,11 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
},
// changes the base price of the product for this orderline
set_unit_price: function(price){
this.price = round_di(parseFloat(price) || 0, this.pos.currency.decimals);
this.price = round_di(parseFloat(price) || 0, this.pos.dp['Product Price']);
this.trigger('change',this);
},
get_unit_price: function(){
var rounding = this.pos.currency.rounding;
return round_pr(this.price,rounding);
return this.price;
},
get_display_price: function(){
var rounding = this.pos.currency.rounding;

View File

@ -18,28 +18,24 @@ function openerp_pos_basewidget(instance, module){ //module is instance.point_of
options = options || {};
this.pos = options.pos || (parent ? parent.pos : undefined);
this.pos_widget = options.pos_widget || (parent ? parent.pos_widget : undefined);
this.build_currency_template();
},
build_currency_template: function(){
format_currency: function(amount,precision){
var currency = (this.pos && this.pos.currency) ? this.pos.currency : {symbol:'$', position: 'after', rounding: 0.01, decimals: 2};
var decimals = currency.decimals;
if(this.pos && this.pos.currency){
this.currency = this.pos.currency;
}else{
this.currency = {symbol: '$', position: 'after', rounding: 0.01};
if (precision && (typeof this.pos.dp[precision]) !== undefined) {
decimals = this.pos.dp[precision];
}
this.format_currency = function(amount){
if(typeof amount === 'number'){
amount = round_di(amount,this.currency.decimals).toFixed(this.currency.decimals);
}
if(this.currency.position === 'after'){
return amount + ' ' + (this.currency.symbol || '');
}else{
return (this.currency.symbol || '') + ' ' + amount;
}
if (typeof amount === 'number') {
amount = round_di(amount,decimals).toFixed(decimals);
}
if (currency.position === 'after') {
return amount + ' ' + (currency.symbol || '');
} else {
return (currency.symbol || '') + ' ' + amount;
}
},
show: function(){
this.$el.removeClass('oe_hidden');

View File

@ -972,7 +972,6 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
$('.oe_web_client').off();
$('.openerp_webclient_container').off();
self.build_currency_template();
self.renderElement();
self.$('.neworder-button').click(function(){

View File

@ -746,12 +746,12 @@
<img t-att-src='image_url' />
<t t-if="!product.to_weight">
<span class="price-tag">
<t t-esc="widget.format_currency(product.price)"/>
<t t-esc="widget.format_currency(product.price,'Product Price')"/>
</span>
</t>
<t t-if="product.to_weight">
<span class="price-tag">
<t t-esc="widget.format_currency(product.price)+'/Kg'"/>
<t t-esc="widget.format_currency(product.price,'Product Price')+'/Kg'"/>
</span>
</t>
</div>
@ -777,7 +777,7 @@
</em>
<t t-esc="line.get_unit().name" />
at
<t t-esc="widget.format_currency(line.get_unit_price())" />
<t t-esc="widget.format_currency(line.get_unit_price(),'Product Price')" />
/
<t t-esc="line.get_unit().name" />
</li>