[REV] point_of_sale: display pricelist button only if enabled"
This reverts commit 7a417e173..03a20ff6cc It should have targeted the master version and be squashed
This commit is contained in:
@@ -294,7 +294,7 @@ exports.PosModel = Backbone.Model.extend({
|
||||
loaded: function(self, locations){ self.shop = locations[0]; },
|
||||
},{
|
||||
model: 'product.pricelist',
|
||||
fields: ['name', 'display_name', 'discount_policy'],
|
||||
fields: ['name', 'display_name'],
|
||||
domain: function(self) { return [['id', 'in', self.config.available_pricelist_ids]]; },
|
||||
loaded: function(self, pricelists){
|
||||
_.map(pricelists, function (pricelist) { pricelist.items = []; });
|
||||
@@ -1306,7 +1306,7 @@ exports.Product = Backbone.Model.extend({
|
||||
// because it would cause inconsistencies with the backend for
|
||||
// pricelist that have base == 'pricelist'.
|
||||
return price;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
var orderline_id = 1;
|
||||
@@ -1557,9 +1557,6 @@ exports.Orderline = Backbone.Model.extend({
|
||||
discount: this.get_discount(),
|
||||
product_name: this.get_product().display_name,
|
||||
product_name_wrapped: this.generate_wrapped_product_name(),
|
||||
price_lst: this.get_lst_price(),
|
||||
display_discount_policy: this.display_discount_policy(),
|
||||
price_display_one: this.get_display_price_one(),
|
||||
price_display : this.get_display_price(),
|
||||
price_with_tax : this.get_price_with_tax(),
|
||||
price_without_tax: this.get_price_without_tax(),
|
||||
@@ -1624,28 +1621,6 @@ exports.Orderline = Backbone.Model.extend({
|
||||
var rounding = this.pos.currency.rounding;
|
||||
return round_pr(this.get_unit_price() * this.get_quantity() * (1 - this.get_discount()/100), rounding);
|
||||
},
|
||||
get_display_price_one: function(){
|
||||
var rounding = this.pos.currency.rounding;
|
||||
var price_unit = this.get_unit_price() * (1.0 - (this.get_discount() / 100.0));
|
||||
if (this.pos.config.iface_tax_included !== 'total') {
|
||||
return round_pr(price_unit, rounding);
|
||||
} else {
|
||||
var product = this.get_product();
|
||||
var taxes_ids = product.taxes_id;
|
||||
var taxes = this.pos.taxes;
|
||||
var product_taxes = [];
|
||||
|
||||
_(taxes_ids).each(function(el){
|
||||
product_taxes.push(_.detect(taxes, function(t){
|
||||
return t.id === el;
|
||||
}));
|
||||
});
|
||||
|
||||
var all_taxes = this.compute_all(product_taxes, price_unit, 1, this.pos.currency.rounding);
|
||||
|
||||
return round_pr(all_taxes.total_included * (1 - this.get_discount()/100), rounding);
|
||||
}
|
||||
},
|
||||
get_display_price: function(){
|
||||
if (this.pos.config.iface_tax_included === 'total') {
|
||||
return this.get_price_with_tax();
|
||||
@@ -1805,12 +1780,6 @@ exports.Orderline = Backbone.Model.extend({
|
||||
"taxDetails": taxdetail,
|
||||
};
|
||||
},
|
||||
display_discount_policy: function(){
|
||||
return this.order.pricelist.discount_policy;
|
||||
},
|
||||
get_lst_price: function(){
|
||||
return this.product.lst_price;
|
||||
},
|
||||
});
|
||||
|
||||
var OrderlineCollection = Backbone.Collection.extend({
|
||||
@@ -2374,11 +2343,10 @@ exports.Order = Backbone.Model.extend({
|
||||
}
|
||||
if (to_merge_orderline){
|
||||
to_merge_orderline.merge(line);
|
||||
this.select_orderline(to_merge_orderline);
|
||||
} else {
|
||||
this.orderlines.add(line);
|
||||
this.select_orderline(this.get_last_orderline());
|
||||
}
|
||||
this.select_orderline(this.get_last_orderline());
|
||||
|
||||
if(line.has_product_lot){
|
||||
this.display_lot_popup();
|
||||
@@ -2481,9 +2449,7 @@ exports.Order = Backbone.Model.extend({
|
||||
},
|
||||
get_total_discount: function() {
|
||||
return round_pr(this.orderlines.reduce((function(sum, orderLine) {
|
||||
sum += (orderLine.get_unit_price() * (orderLine.get_discount()/100) * orderLine.get_quantity());
|
||||
sum += ((orderLine.get_lst_price() - orderLine.get_unit_price()) * orderLine.get_quantity());
|
||||
return sum;
|
||||
return sum + (orderLine.get_unit_price() * (orderLine.get_discount()/100) * orderLine.get_quantity());
|
||||
}), 0), this.pos.currency.rounding);
|
||||
},
|
||||
get_total_tax: function() {
|
||||
|
||||
@@ -2232,7 +2232,7 @@ define_action_button({
|
||||
'name': 'set_pricelist',
|
||||
'widget': set_pricelist_button,
|
||||
'condition': function(){
|
||||
return this.pos.config.use_pricelist && this.pos.pricelists.length > 1;
|
||||
return this.pos.pricelists.length > 1;
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -775,44 +775,19 @@
|
||||
|
||||
<div class='orderlines' line-ratio='0.6'>
|
||||
<t t-foreach='receipt.orderlines' t-as='line'>
|
||||
<t t-set='simple' t-value='(line.discount === 0 and line.unit_name === "Unit(s)" and line.quantity === 1 and !discount_to_show and !(line.display_discount_policy == "without_discount" && line.price != line.price_lst))' />
|
||||
<t t-set='simple' t-value='line.discount === 0 and line.unit_name === "Unit(s)" and line.quantity === 1' />
|
||||
<t t-if='simple'>
|
||||
<line>
|
||||
<left><t t-esc='line.product_name_wrapped[0]' /></left>
|
||||
<right><value t-att-value-decimals='pos.currency.decimals'><t t-esc='line.price_display' /></value></right>
|
||||
</line>
|
||||
<t t-call="XmlReceiptWrappedProductNameLines"/>
|
||||
</t>
|
||||
<t t-call="XmlReceiptWrappedProductNameLines"/>
|
||||
<t t-if='!simple'>
|
||||
<line><left><t t-esc='line.product_name_wrapped[0]' /></left></line>
|
||||
<t t-call="XmlReceiptWrappedProductNameLines"/>
|
||||
<t t-if="line.display_discount_policy == 'without_discount' && line.price != line.price_lst">
|
||||
<line indent='1'>
|
||||
<left>
|
||||
<value t-att-value-decimals='pos.dp["Product Price"]'>
|
||||
<t t-esc="line.price_lst" />
|
||||
</value> ->
|
||||
<value t-att-value-decimals='pos.dp["Product Price"]'>
|
||||
<t t-esc="line.price" />
|
||||
</value>
|
||||
</left>
|
||||
</line>
|
||||
</t>
|
||||
<t t-else='line.discount !== 0'>
|
||||
<line indent='1'>
|
||||
<left>
|
||||
<value t-att-value-decimals='pos.dp["Product Price"]'>
|
||||
<t t-esc="line.price_lst" />
|
||||
</value>
|
||||
</left>
|
||||
</line>
|
||||
</t>
|
||||
<t t-if='line.discount !== 0'>
|
||||
<line indent='1'>
|
||||
<left>
|
||||
Discount: <t t-esc='line.discount' />%
|
||||
</left>
|
||||
</line>
|
||||
<line indent='1'><left>Discount: <t t-esc='line.discount' />%</left></line>
|
||||
</t>
|
||||
<line indent='1'>
|
||||
<left>
|
||||
@@ -824,7 +799,7 @@
|
||||
</t>
|
||||
x
|
||||
<value t-att-value-decimals='pos.dp["Product Price"]'>
|
||||
<t t-esc='line.price_display_one' />
|
||||
<t t-esc='line.price' />
|
||||
</value>
|
||||
</left>
|
||||
<right>
|
||||
@@ -1294,7 +1269,7 @@
|
||||
<t t-if="line.get_product().tracking!=='none'">
|
||||
<i class="oe_link_icon fa fa-list oe_icon line-lot-icon oe_green" t-if="line.has_valid_product_lot()"
|
||||
aria-label="Valid product lot" role="img" title="Valid product lot"/>
|
||||
<i class="oe_link_icon fa fa-list oe_icon line-lot-icon oe_red" t-if="!line.has_valid_product_lot()"
|
||||
<i class="oe_link_icon fa fa-list oe_icon line-lot-icon oe_red" t-if="not(line.has_valid_product_lot())"
|
||||
aria-label="Invalid product lot" role="img" title="Invalid product lot"/>
|
||||
</t>
|
||||
</span>
|
||||
@@ -1309,16 +1284,7 @@
|
||||
</em>
|
||||
<t t-esc="line.get_unit().name" />
|
||||
at
|
||||
<t t-if="line.display_discount_policy() == 'without_discount' &&
|
||||
line.get_unit_display_price() != line.get_lst_price()">
|
||||
<s>
|
||||
<t t-esc="widget.format_currency(line.get_lst_price(),'Product Price')" />
|
||||
</s>
|
||||
<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="widget.format_currency(line.get_unit_display_price(),'Product Price')" />
|
||||
/
|
||||
<t t-esc="line.get_unit().name" />
|
||||
</li>
|
||||
@@ -1506,15 +1472,6 @@
|
||||
<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' &&
|
||||
orderline.get_unit_display_price() != orderline.get_lst_price()">
|
||||
<div class="pos-disc-font">
|
||||
<s>
|
||||
<t t-esc="widget.format_currency(orderline.get_lst_price(),'Product Price')"/>
|
||||
</s> ->
|
||||
<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
|
||||
|
||||
@@ -273,7 +273,6 @@ class TestUi(odoo.tests.HttpCase):
|
||||
'type': 'cash',
|
||||
'company_id': main_company.id,
|
||||
'journal_user': True})],
|
||||
'use_pricelist': True,
|
||||
'available_pricelist_ids': [(4, pricelist.id) for pricelist in all_pricelists],
|
||||
})
|
||||
|
||||
|
||||
@@ -37,11 +37,6 @@ 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]
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
from . import analytic
|
||||
from . import account_invoice
|
||||
from . import product_pricelist
|
||||
from . import product_product
|
||||
from . import product_template
|
||||
from . import res_company
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# -*- 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')
|
||||
Reference in New Issue
Block a user