[IMP] pos_discount: a new pos extension that allows you to quickly give a global discount on the current order
This commit is contained in:
parent
28de2183ea
commit
cb725a973d
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import discount
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
{
|
||||
'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:
|
|
@ -0,0 +1,39 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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,
|
||||
}
|
||||
|
|
@ -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');
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="DiscountButton">
|
||||
<div class='control-button js_discount'>
|
||||
Discount
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<template id="assets_frontend" inherit_id="web.assets_common">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/pos_discount/static/src/js/discount.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_pos_config_form">
|
||||
<field name="name">pos.config.form.view</field>
|
||||
<field name="model">pos.config</field>
|
||||
<field name="inherit_id" ref="point_of_sale.view_pos_config_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@string='Receipt']" position="after">
|
||||
<group string="Discounts" col="4" >
|
||||
<field name='discount_pc' />
|
||||
<field name="discount_product_id" />
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue