2010-03-18 12:25:58 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
2010-03-29 12:38:53 +00:00
|
|
|
#
|
2010-03-18 12:25:58 +00:00
|
|
|
# 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
|
2010-03-29 12:38:53 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-03-18 12:25:58 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import osv, fields
|
2010-03-29 12:38:53 +00:00
|
|
|
|
[REM] removed details_summary, sales_user, sales_user_today, payment_user reports, wizards and rml
[REM] dead code: pos_box_entries.py/xml, pos_box_out.py/xml, pos_return_view.py/xml
[ADD] lines, invoice, cashbox of the day, payment, receipt, users product reports converted to QWeb. Added YML tests for the bank statement reports.
[FIX] closed cashbox of the day sql using old fields in its queries, yml test not correctly generating an invoice from a pos order
bzr revid: sle@openerp.com-20140414104954-xj10wi640tyr3ufe
2014-04-14 10:49:54 +00:00
|
|
|
|
2010-03-18 12:25:58 +00:00
|
|
|
class pos_discount(osv.osv_memory):
|
|
|
|
_name = 'pos.discount'
|
2011-09-25 14:09:30 +00:00
|
|
|
_description = 'Add a Global Discount'
|
2010-03-18 12:25:58 +00:00
|
|
|
_columns = {
|
2011-09-25 14:09:30 +00:00
|
|
|
'discount': fields.float('Discount (%)', required=True, digits=(16,2)),
|
2010-03-18 12:25:58 +00:00
|
|
|
}
|
|
|
|
_defaults = {
|
2010-10-26 13:40:31 +00:00
|
|
|
'discount': 5,
|
2010-03-19 05:54:25 +00:00
|
|
|
}
|
2010-03-29 12:38:53 +00:00
|
|
|
|
2010-10-26 13:40:31 +00:00
|
|
|
def apply_discount(self, cr, uid, ids, context=None):
|
2010-03-29 12:38:53 +00:00
|
|
|
"""
|
2010-03-19 05:54:25 +00:00
|
|
|
To give the discount of product and check the.
|
2010-03-29 12:38:53 +00:00
|
|
|
|
2010-03-19 05:54:25 +00:00
|
|
|
@param self: The object pointer.
|
|
|
|
@param cr: A database cursor
|
|
|
|
@param uid: ID of the user currently logged in
|
2010-03-29 12:38:53 +00:00
|
|
|
@param context: A standard dictionary
|
2010-03-19 05:54:25 +00:00
|
|
|
@return : nothing
|
2010-03-29 12:38:53 +00:00
|
|
|
"""
|
2010-10-26 13:40:31 +00:00
|
|
|
order_ref = self.pool.get('pos.order')
|
|
|
|
order_line_ref = self.pool.get('pos.order.line')
|
|
|
|
if context is None:
|
|
|
|
context = {}
|
2010-03-18 12:25:58 +00:00
|
|
|
this = self.browse(cr, uid, ids[0], context=context)
|
2010-03-19 07:26:34 +00:00
|
|
|
record_id = context and context.get('active_id', False)
|
2010-03-18 12:25:58 +00:00
|
|
|
if isinstance(record_id, (int, long)):
|
2010-03-29 12:38:53 +00:00
|
|
|
record_id = [record_id]
|
2010-03-18 12:25:58 +00:00
|
|
|
for order in order_ref.browse(cr, uid, record_id, context=context):
|
2011-09-25 14:09:30 +00:00
|
|
|
order_line_ref.write(cr, uid, [x.id for x in order.lines], {'discount':this.discount}, context=context)
|
2010-03-18 12:25:58 +00:00
|
|
|
return {}
|
2010-03-19 05:54:25 +00:00
|
|
|
|
2010-03-18 12:25:58 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|