diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py deleted file mode 100644 index 1b5860cef1c..00000000000 --- a/addons/point_of_sale/wizard/pos_return.py +++ /dev/null @@ -1,596 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved -# $Id$ -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################################## - -#import wizard -#import pooler -#from tools.misc import UpdateableStr -# -#import netsvc -#import time -# -#from tools.translate import _ -#from decimal import Decimal - -#arch=UpdateableStr() -#fields={} - -import netsvc -from osv import osv,fields -from tools.translate import _ -from mx import DateTime -import time - - -class pos_return(osv.osv_memory): - _name = 'pos.return' - _description = 'Point of sale return' - - _columns = { - - } -pos_return() - -class pos_add_payment(osv.osv_memory): - _name = 'pos.add.payment' - _description = 'Add Payment' - - _columns = { - 'amount': fields.float('Amount', digits=(16,2),required=True), - 'journal': fields.function(_get_journal, 'Journal', method=True, required=True), - 'payment_date': fields.date('Payment date',required=True), - 'payment_name': fields.char('Payment name', size=32,required=True), - 'invoice_wanted': fields.boolean('Invoice'), - 'num_sale': fields.char('Num.Cof', size=32) - } - _defaults = { - 'payment_name': lambda *a: 'Payment' - } - -pos_add_payment() - -class pos_add_product(osv.osv_memory): - _name = 'pos.add.product' - _description = 'Add Product' - - _columns = { - 'product': fields.many2one('product.product','Product', required=True), - 'quantity': fields.integer( 'Quantity',required=True), - - } - - _defaults = { - 'product': lambda *a: 'False', - 'quantity': lambda *a: 1 - } - -pos_add_product() - - -def _get_journal(self, cr, uid, context): - pool = pooler.get_pool(cr.dbname) - obj = pool.get('account.journal') - c=pool.get('res.users').browse(cr,uid,uid).company_id.id - ids = obj.search(cr, uid, [('type', '=', 'cash'), ('company_id','=',c)]) - res = obj.read(cr, uid, ids, ['id', 'name'], context) - res = [(r['id'], r['name']) for r in res] - return res - - -payment_form = """ -
- - - - - - - -""" - -payment_fields = { - 'amount': {'string': 'Amount', 'type': 'float', 'required': True}, - 'invoice_wanted': {'string': 'Invoice', 'type': 'boolean'}, - 'journal': {'string': 'Journal', - 'type': 'selection', - 'selection': _get_journal, - 'required': True, - }, - 'payment_date': {'string': 'Payment date', 'type': 'date', 'required': True}, - 'payment_name': {'string': 'Payment name', 'type': 'char', 'size': '32', 'required':True, 'default':'Payment'}, - 'num_sale': {'string': 'Num.Cof', 'type': 'char', 'size': '32'}, - } - - -def _pre_init(self, cr, uid, data, context): - def _get_journal(pool, order): - j_obj = pool.get('account.journal') - - journal_to_fetch = 'DEFAULT' - if order.amount_total < 0: - journal_to_fetch = 'GIFT' - else: - if order.amount_paid > 0: - journal_to_fetch = 'REBATE' - - pos_config_journal = pool.get('pos.config.journal') - ids = pos_config_journal.search(cr, uid, [('code', '=', journal_to_fetch)]) - objs = pos_config_journal.browse(cr, uid, ids) - journal='' - if objs: - journal = objs[0].journal_id.id - else: - existing = [payment.journal_id.id for payment in order.payments] - ids = j_obj.search(cr, uid, [('type', '=', 'cash')]) - for i in ids: - if i not in existing: - journal = i - break - if not journal: - journal = ids and ids[0] - return journal - pool = pooler.get_pool(cr.dbname) - order = pool.get('pos.order').browse(cr, uid, data['id'], context) - # get amount to pay: -# amount = Decimal(str(order.amount_total)) - Decimal(str(order.amount_paid)) - amount = order.amount_total - order.amount_paid - if amount <= 0: - pool.get('pos.order').action_paid(cr, uid, data['ids'], context) - - # get journal: - journal = _get_journal(pool, order) - - # check if an invoice is wanted: - #invoice_wanted_checked = not not order.partner_id # not not -> boolean - invoice_wanted_checked = False - - # select the current date - current_date = time.strftime('%Y-%m-%d') - - return {'journal': journal, 'amount': amount, 'invoice_wanted': invoice_wanted_checked, 'payment_date': current_date} - - -def _add_pay(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - order_obj = pool.get('pos.order') - jrnl_obj = pool.get('account.journal') - result = data['form'] - invoice_wanted = data['form']['invoice_wanted'] - jrnl_used=False - if data['form'] and data['form'].get('journal',False): - jrnl_used=jrnl_obj.browse(cr,uid,data['form']['journal']) - - # add 'invoice_wanted' in 'pos.order' - order_obj.write(cr, uid, [data['id']], {'invoice_wanted': invoice_wanted}) - - order_obj.add_payment(cr, uid, data['id'], result, context=context) - return {} - - -def _check(self, cr, uid, data, context): - """Check the order: - if the order is not paid: continue payment, - if the order is paid print invoice (if wanted) or ticket. - """ - pool = pooler.get_pool(cr.dbname) - order_obj = pool.get('pos.order') - order = order_obj.browse(cr, uid, data['id'], context) - order_obj.test_order_lines(cr, uid, order, context=context) - - action = 'ask_pay' - if order.state == 'paid': - if order.partner_id: - if order.invoice_wanted: - action = 'invoice' - else: - action = 'paid' - elif order.date_payment: - action = 'receipt' - else: - action='paid' - - if order.amount_total == order.amount_paid: - order_obj.write(cr,uid,data['ids'],{'state':'done'}) - action = 'receipt' - - return action - - -def create_invoice(self, cr, uid, data, context): - wf_service = netsvc.LocalService("workflow") - for i in data['ids']: - wf_service.trg_validate(uid, 'pos.order', i, 'invoice', cr) - return {} - - - -_form = """ -
- - - -""" -_fields = { - 'product': { - 'string': 'Product', - 'type': 'many2one', - 'relation': 'product.product', - 'required': True, - 'default': False - }, - - 'quantity': { - 'string': 'Quantity', - 'type': 'integer', - 'required': True, - 'default': 1}, - } - -def make_default(val): - def fct(obj, cr, uid): - return val - return fct - -def _get_returns(self, cr, uid, data, context): - - pool = pooler.get_pool(cr.dbname) - order_obj=pool.get('pos.order') - order=order_obj.browse(cr, uid, [data['id']])[0] - res={} - fields.clear() - arch_lst=['', '
' % _('Return lines'), '