diff --git a/pos_pricelist/__init__.py b/pos_pricelist/__init__.py
index 6d755589..8b20599f 100644
--- a/pos_pricelist/__init__.py
+++ b/pos_pricelist/__init__.py
@@ -16,3 +16,4 @@
# along with this program. If not, see .
#
##############################################################################
+from . import models
diff --git a/pos_pricelist/__openerp__.py b/pos_pricelist/__openerp__.py
index e63ebd86..c4654eed 100644
--- a/pos_pricelist/__openerp__.py
+++ b/pos_pricelist/__openerp__.py
@@ -33,10 +33,14 @@ New feature for the Point Of Sale:
],
'data': [
"views/pos_pricelist_template.xml",
+ "views/pos_pricelist_views.xml",
],
'demo': [
'demo/pos_pricelist_demo.yml',
],
+ 'qweb': [
+ 'static/src/xml/pos.xml'
+ ],
'installable': True,
'application': False,
'auto_install': False,
diff --git a/pos_pricelist/models/__init__.py b/pos_pricelist/models/__init__.py
new file mode 100644
index 00000000..6edd473a
--- /dev/null
+++ b/pos_pricelist/models/__init__.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# Point Of Sale - Pricelist for POS Odoo
+# Copyright (C) 2015 Taktik (http://www.taktik.be)
+# @author Adil Houmadi
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from . import pos_pricelist
diff --git a/pos_pricelist/models/pos_pricelist.py b/pos_pricelist/models/pos_pricelist.py
new file mode 100644
index 00000000..9b137645
--- /dev/null
+++ b/pos_pricelist/models/pos_pricelist.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# Point Of Sale - Pricelist for POS Odoo
+# Copyright (C) 2015 Taktik (http://www.taktik.be)
+# @author Adil Houmadi
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from openerp import models, fields
+
+class PosPriceListConfig(models.Model):
+ _inherit = 'pos.config'
+
+ display_price_with_taxes = fields.Boolean(
+ string='Price With Taxes',
+ help="Display Prices with taxes on POS"
+ )
diff --git a/pos_pricelist/static/src/js/db.js b/pos_pricelist/static/src/js/db.js
index 7da31689..12458860 100644
--- a/pos_pricelist/static/src/js/db.js
+++ b/pos_pricelist/static/src/js/db.js
@@ -1,20 +1,20 @@
/******************************************************************************
-* Point Of Sale - Pricelist for POS Odoo
-* Copyright (C) 2014 Taktik (http://www.taktik.be)
-* @author Adil Houmadi
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Affero General Public License as
-* published by the Free Software Foundation, either version 3 of the
-* License, or (at your option) any later version.
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Affero General Public License for more details.
-* You should have received a copy of the GNU Affero General Public License
-* along with this program. If not, see .
-*
-******************************************************************************/
+ * Point Of Sale - Pricelist for POS Odoo
+ * Copyright (C) 2014 Taktik (http://www.taktik.be)
+ * @author Adil Houmadi
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ ******************************************************************************/
function pos_pricelist_db(instance, module) {
module.PosDB = module.PosDB.extend({
@@ -156,6 +156,24 @@ function pos_pricelist_db(instance, module) {
}
}
return taxes;
+ },
+ add_products: function (products) {
+ this._super(products);
+ var pos = posmodel.pos_widget.pos;
+ for (var id in this.product_by_id) {
+ if (this.product_by_id.hasOwnProperty(id)) {
+ var product = this.product_by_id[id];
+ var orderline = new openerp.point_of_sale.Orderline({}, {
+ pos: pos,
+ order: null,
+ product: product,
+ price: product.price
+ });
+ var prices = orderline.get_all_prices();
+ this.product_by_id[id].price_with_taxes
+ = prices['priceWithTax']
+ }
+ }
}
})
}
diff --git a/pos_pricelist/static/src/js/models.js b/pos_pricelist/static/src/js/models.js
index e79fb3e1..f1656d42 100644
--- a/pos_pricelist/static/src/js/models.js
+++ b/pos_pricelist/static/src/js/models.js
@@ -1,20 +1,20 @@
/******************************************************************************
-* Point Of Sale - Pricelist for POS Odoo
-* Copyright (C) 2014 Taktik (http://www.taktik.be)
-* @author Adil Houmadi
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Affero General Public License as
-* published by the Free Software Foundation, either version 3 of the
-* License, or (at your option) any later version.
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Affero General Public License for more details.
-* You should have received a copy of the GNU Affero General Public License
-* along with this program. If not, see .
-*
-******************************************************************************/
+ * Point Of Sale - Pricelist for POS Odoo
+ * Copyright (C) 2014 Taktik (http://www.taktik.be)
+ * @author Adil Houmadi
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ ******************************************************************************/
function pos_pricelist_models(instance, module) {
var _t = instance.web._t;
@@ -137,10 +137,10 @@ function pos_pricelist_models(instance, module) {
initialize: function (attr, options) {
this.constructor.__super__.initialize.apply(this, arguments);
this.manuel_price = false;
- if (options.product !== undefined) {
- var qty = this.compute_qty(options.order, options.product);
- var partner = options.order.get_client();
- var product = options.product;
+ if (this.product !== undefined) {
+ var qty = this.compute_qty(this.order, this.product);
+ var partner = this.order ? this.order.get_client() : null;
+ var product = this.product;
var db = this.pos.db;
var price = this.pos.pricelist_engine.compute_price_all(
db, product, partner, qty
@@ -194,7 +194,7 @@ function pos_pricelist_models(instance, module) {
var taxdetail = {};
// Add by pos_pricelist
- var partner = this.order.get_client();
+ var partner = this.order ? this.order.get_client() : null;
var fiscal_position_taxes = [];
if (partner && partner.property_account_position) {
fiscal_position_taxes =
@@ -310,7 +310,7 @@ function pos_pricelist_models(instance, module) {
compute_qty: function (order, product) {
var qty = 1;
var orderlines = [];
- if (order.get('orderLines').models !== undefined) {
+ if (order && order.get('orderLines').models !== undefined) {
orderlines = order.get('orderLines').models;
}
for (var i = 0; i < orderlines.length; i++) {
@@ -502,7 +502,7 @@ function pos_pricelist_models(instance, module) {
var price_limit = price;
price = price * (1.0 + (rule['price_discount']
? rule['price_discount']
- : 0.0))
+ : 0.0));
if (rule['price_round']) {
price = parseFloat(price.toFixed(
Math.ceil(Math.log(1.0 / rule['price_round'])
@@ -540,9 +540,28 @@ function pos_pricelist_models(instance, module) {
for (var i = 0, len = product_list_ui.length; i < len; i++) {
var product_ui = product_list_ui[i];
var product_id = $(product_ui).data('product-id');
- var product = db.get_product_by_id(product_id);
+ // price which computed via pricelist
+ var product = $.extend({}, db.get_product_by_id(product_id));
var price = this.compute_price_all(db, product, partner, 1);
if (price !== false && price !== 0.0) {
+ if (this.pos.config.display_price_with_taxes) {
+ // create a fake order in order to get price
+ // for this customer
+ var order = new module.Order({pos: this.pos});
+ order.set_client(partner);
+ var orderline = new openerp.point_of_sale.Orderline({},
+ {
+ pos: this.pos,
+ order: order,
+ product: product,
+ price: price
+ }
+ );
+ // reset the sequence
+ this.pos.pos_session.sequence_number--;
+ var prices = orderline.get_all_prices();
+ price = prices['priceWithTax'];
+ }
price = round_di(parseFloat(price)
|| 0, this.pos.dp['Product Price']);
price = this.pos_widget.format_currency(price);
@@ -571,7 +590,6 @@ function pos_pricelist_models(instance, module) {
}
}
});
-
/**
* show error
* @param context
diff --git a/pos_pricelist/static/src/js/widgets.js b/pos_pricelist/static/src/js/widgets.js
index 05420eb0..5a04e7ea 100644
--- a/pos_pricelist/static/src/js/widgets.js
+++ b/pos_pricelist/static/src/js/widgets.js
@@ -38,6 +38,21 @@ function pos_pricelist_widgets(instance, module) {
: false;
this.pos.pricelist_engine.update_products_ui(partner);
}
- })
+ });
+
+ instance.point_of_sale.ProductListWidget.include({
+ init: function (parent, options) {
+ this._super(parent, options);
+ this.display_price_with_taxes = false;
+ if (
+ posmodel
+ && posmodel.config
+ && posmodel.config.display_price_with_taxes
+ ) {
+ this.display_price_with_taxes
+ = posmodel.config.display_price_with_taxes
+ }
+ }
+ });
}
diff --git a/pos_pricelist/static/src/xml/pos.xml b/pos_pricelist/static/src/xml/pos.xml
new file mode 100644
index 00000000..0a12299f
--- /dev/null
+++ b/pos_pricelist/static/src/xml/pos.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pos_pricelist/views/pos_pricelist_views.xml b/pos_pricelist/views/pos_pricelist_views.xml
new file mode 100644
index 00000000..084723e7
--- /dev/null
+++ b/pos_pricelist/views/pos_pricelist_views.xml
@@ -0,0 +1,15 @@
+
+
+
+
+ view.pos.config.form.pos.pricelist
+ pos.config
+
+
+
+
+
+
+
+
+