[IMP] point of sale : Show discount when option enabled on pricelist

Many users are confused when using pricelists on the PoS :
When they tick the box "Show discount" on the pricelist, it has no impact when the pricelist is applied on the PoS.
They often report a ticket thinking it's a bug.

It can be useful to show the discount on the PoS when applying a pricelist, when users benefit from a preferred price,
the vendor often wants to show it to the customer.
This commit is contained in:
lejeune quentin
2018-09-28 15:01:46 +02:00
committed by Gert Pellin - GPE
parent 799fb5e6f0
commit 088044811d
5 changed files with 38 additions and 17 deletions
+13 -2
View File
@@ -294,7 +294,7 @@ exports.PosModel = Backbone.Model.extend({
loaded: function(self, locations){ self.shop = locations[0]; },
},{
model: 'product.pricelist',
fields: ['name', 'display_name'],
fields: ['name', 'display_name', 'discount_policy'],
domain: function(self) { return [['id', 'in', self.config.available_pricelist_ids]]; },
loaded: function(self, pricelists){
_.map(pricelists, function (pricelist) { pricelist.items = []; });
@@ -1306,6 +1306,9 @@ exports.Product = Backbone.Model.extend({
// because it would cause inconsistencies with the backend for
// pricelist that have base == 'pricelist'.
return price;
},
get_discount_policy: function(pricelist){
return pricelist.discount_policy;
},
});
@@ -1780,6 +1783,12 @@ exports.Orderline = Backbone.Model.extend({
"taxDetails": taxdetail,
};
},
display_discount_policy: function(){
return this.product.get_discount_policy(this.order.pricelist);
},
get_list_price: function(){
return this.product.list_price;
},
});
var OrderlineCollection = Backbone.Collection.extend({
@@ -2450,7 +2459,9 @@ exports.Order = Backbone.Model.extend({
},
get_total_discount: function() {
return round_pr(this.orderlines.reduce((function(sum, orderLine) {
return sum + (orderLine.get_unit_price() * (orderLine.get_discount()/100) * orderLine.get_quantity());
sum += (orderLine.get_unit_price() * (orderLine.get_discount()/100) * orderLine.get_quantity());
sum += ((orderLine.get_list_price() - orderLine.get_unit_price()) * orderLine.get_quantity());
return sum
}), 0), this.pos.currency.rounding);
},
get_total_tax: function() {
+20 -1
View File
@@ -1284,7 +1284,16 @@
</em>
<t t-esc="line.get_unit().name" />
at
<t t-esc="widget.format_currency(line.get_unit_display_price(),'Product Price')" />
<t t-if="line.display_discount_policy() == 'without_discount' &amp;&amp;
line.get_unit_display_price() != line.get_list_price()">
<strike>
<t t-esc="widget.format_currency(line.get_list_price(),'Product List Price')" />
</strike>
<t t-esc="widget.format_currency(line.get_unit_display_price(),'Product Price')" />
</t>
<t t-else="">
<t t-esc="widget.format_currency(line.get_unit_display_price(),'Product Price')" />
</t>
/
<t t-esc="line.get_unit().name" />
</li>
@@ -1472,6 +1481,16 @@
<tr t-foreach="orderlines" t-as="orderline">
<td>
<t t-esc="orderline.get_product().display_name"/>
<t t-if="orderline.display_discount_policy() == 'without_discount' &amp;&amp;
orderline.get_unit_display_price() != orderline.get_list_price()">
<div class="pos-disc-font">
<strike>
<t t-esc="widget.format_currency(orderline.get_list_price(),'Product List Price')"/>
</strike>
->
<t t-esc="widget.format_currency(orderline.get_unit_display_price(),'Product Price')"/>
</div>
</t>
<t t-if="orderline.get_discount() > 0">
<div class="pos-disc-font">
With a <t t-esc="orderline.get_discount()"/>% discount
@@ -37,6 +37,11 @@ class Pricelist(models.Model):
country_group_ids = fields.Many2many('res.country.group', 'res_country_group_pricelist_rel',
'pricelist_id', 'res_country_group_id', string='Country Groups')
discount_policy = fields.Selection([
('with_discount', 'Discount included in the price'),
('without_discount', 'Show public price & discount to the customer')],
default='with_discount')
@api.multi
def name_get(self):
return [(pricelist.id, '%s (%s)' % (pricelist.name, pricelist.currency_id.name)) for pricelist in self]
-1
View File
@@ -3,7 +3,6 @@
from . import analytic
from . import account_invoice
from . import product_pricelist
from . import product_product
from . import product_template
from . import res_company
-13
View File
@@ -1,13 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class ProductPricelist(models.Model):
_inherit = 'product.pricelist'
discount_policy = fields.Selection([
('with_discount', 'Discount included in the price'),
('without_discount', 'Show public price & discount to the customer')],
default='with_discount')