[FIX] point_of_sale: use 'Product Price' decimal precision for product prices
This commit is contained in:
parent
d1fb79ad14
commit
95e79c9f6f
|
@ -138,6 +138,15 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||||
fields: [ 'currency_id', 'email', 'website', 'company_registry', 'vat', 'name', 'phone', 'partner_id' , 'country_id'],
|
fields: [ 'currency_id', 'email', 'website', 'company_registry', 'vat', 'name', 'phone', 'partner_id' , 'country_id'],
|
||||||
ids: function(self){ return [self.user.company_id[0]] },
|
ids: function(self){ return [self.user.company_id[0]] },
|
||||||
loaded: function(self,companies){ self.company = companies[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',
|
model: 'product.uom',
|
||||||
fields: [],
|
fields: [],
|
||||||
|
@ -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
|
// changes the base price of the product for this orderline
|
||||||
set_unit_price: function(price){
|
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);
|
this.trigger('change',this);
|
||||||
},
|
},
|
||||||
get_unit_price: function(){
|
get_unit_price: function(){
|
||||||
var rounding = this.pos.currency.rounding;
|
return this.price;
|
||||||
return round_pr(this.price,rounding);
|
|
||||||
},
|
},
|
||||||
get_display_price: function(){
|
get_display_price: function(){
|
||||||
var rounding = this.pos.currency.rounding;
|
var rounding = this.pos.currency.rounding;
|
||||||
|
|
|
@ -18,28 +18,24 @@ function openerp_pos_basewidget(instance, module){ //module is instance.point_of
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.pos = options.pos || (parent ? parent.pos : undefined);
|
this.pos = options.pos || (parent ? parent.pos : undefined);
|
||||||
this.pos_widget = options.pos_widget || (parent ? parent.pos_widget : 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){
|
if (precision && (typeof this.pos.dp[precision]) !== undefined) {
|
||||||
this.currency = this.pos.currency;
|
decimals = this.pos.dp[precision];
|
||||||
}else{
|
|
||||||
this.currency = {symbol: '$', position: 'after', rounding: 0.01};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof amount === 'number') {
|
||||||
this.format_currency = function(amount){
|
amount = round_di(amount,decimals).toFixed(decimals);
|
||||||
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 (currency.position === 'after') {
|
||||||
|
return amount + ' ' + (currency.symbol || '');
|
||||||
|
} else {
|
||||||
|
return (currency.symbol || '') + ' ' + amount;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
show: function(){
|
show: function(){
|
||||||
this.$el.removeClass('oe_hidden');
|
this.$el.removeClass('oe_hidden');
|
||||||
|
|
|
@ -972,7 +972,6 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
||||||
$('.oe_web_client').off();
|
$('.oe_web_client').off();
|
||||||
$('.openerp_webclient_container').off();
|
$('.openerp_webclient_container').off();
|
||||||
|
|
||||||
self.build_currency_template();
|
|
||||||
self.renderElement();
|
self.renderElement();
|
||||||
|
|
||||||
self.$('.neworder-button').click(function(){
|
self.$('.neworder-button').click(function(){
|
||||||
|
|
|
@ -746,12 +746,12 @@
|
||||||
<img t-att-src='image_url' />
|
<img t-att-src='image_url' />
|
||||||
<t t-if="!product.to_weight">
|
<t t-if="!product.to_weight">
|
||||||
<span class="price-tag">
|
<span class="price-tag">
|
||||||
<t t-esc="widget.format_currency(product.price)"/>
|
<t t-esc="widget.format_currency(product.price,'Product Price')"/>
|
||||||
</span>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
<t t-if="product.to_weight">
|
<t t-if="product.to_weight">
|
||||||
<span class="price-tag">
|
<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>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
|
@ -777,7 +777,7 @@
|
||||||
</em>
|
</em>
|
||||||
<t t-esc="line.get_unit().name" />
|
<t t-esc="line.get_unit().name" />
|
||||||
at
|
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" />
|
<t t-esc="line.get_unit().name" />
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Reference in New Issue