diff --git a/addons/pos_discount/__init__.py b/addons/pos_discount/__init__.py new file mode 100644 index 00000000000..5487d145a9b --- /dev/null +++ b/addons/pos_discount/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +import discount + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/pos_discount/__openerp__.py b/addons/pos_discount/__openerp__.py new file mode 100644 index 00000000000..d367db148cd --- /dev/null +++ b/addons/pos_discount/__openerp__.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + + +{ + 'name': 'Point of Sale Discounts', + 'version': '1.0', + 'category': 'Point of Sale', + 'sequence': 6, + 'summary': 'Simple Discounts in the Point of Sale ', + 'description': """ + +======================= + +This module allows the cashier to quickly give a percentage +sale discount to a customer. + +""", + 'author': 'OpenERP SA', + 'depends': ['point_of_sale'], + 'data': [ + 'views/views.xml', + 'views/templates.xml' + ], + 'installable': True, + 'auto_install': False, +} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/pos_discount/discount.py b/addons/pos_discount/discount.py new file mode 100644 index 00000000000..f8d24eb638b --- /dev/null +++ b/addons/pos_discount/discount.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +import logging + +import openerp + +from openerp import tools +from openerp.osv import fields, osv +from openerp.tools.translate import _ + +class pos_config(osv.osv): + _inherit = 'pos.config' + _columns = { + 'discount_pc': fields.float('Discount Percentage', help='The discount percentage'), + 'discount_product_id': fields.many2one('product.product','Discount Product', help='The product used to model the discount'), + } + _defaults = { + 'discount_pc': 10, + } + diff --git a/addons/pos_discount/static/src/js/discount.js b/addons/pos_discount/static/src/js/discount.js new file mode 100644 index 00000000000..5eaab362d20 --- /dev/null +++ b/addons/pos_discount/static/src/js/discount.js @@ -0,0 +1,34 @@ +openerp.pos_discount = function(instance){ + var module = instance.point_of_sale; + var round_pr = instance.web.round_precision + var QWeb = instance.web.qweb; + + QWeb.add_template('/pos_discount/static/src/xml/discount.xml'); + + module.PosWidget.include({ + build_widgets: function(){ + var self = this; + this._super(); + + if(!this.pos.config.discount_product_id){ + return; + } + + var discount = $(QWeb.render('DiscountButton')); + + discount.click(function(){ + var order = self.pos.get('selectedOrder'); + var product = self.pos.db.get_product_by_id(self.pos.config.discount_product_id[0]); + var discount = - self.pos.config.discount_pc/ 100.0 * order.getTotalTaxIncluded(); + if( discount < 0 ){ + order.addProduct(product, { price: discount }); + } + }); + + discount.appendTo(this.$('.control-buttons')); + this.$('.control-buttons').removeClass('oe_hidden'); + }, + }); + +}; + diff --git a/addons/pos_discount/static/src/xml/discount.xml b/addons/pos_discount/static/src/xml/discount.xml new file mode 100644 index 00000000000..c8be941683f --- /dev/null +++ b/addons/pos_discount/static/src/xml/discount.xml @@ -0,0 +1,10 @@ + + + + +
+ Discount +
+
+ +
diff --git a/addons/pos_discount/views/templates.xml b/addons/pos_discount/views/templates.xml new file mode 100644 index 00000000000..0dbf22eb0fe --- /dev/null +++ b/addons/pos_discount/views/templates.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/addons/pos_discount/views/views.xml b/addons/pos_discount/views/views.xml new file mode 100644 index 00000000000..3448e0b2b6f --- /dev/null +++ b/addons/pos_discount/views/views.xml @@ -0,0 +1,20 @@ + + + + + + pos.config.form.view + pos.config + + + + + + + + + + + + +