diff --git a/addons/auction/wizard/auction_lots_cancel.py b/addons/auction/wizard/auction_lots_cancel.py index 91f38a364e0..117f9b5eb78 100644 --- a/addons/auction/wizard/auction_lots_cancel.py +++ b/addons/auction/wizard/auction_lots_cancel.py @@ -30,25 +30,25 @@ class auction_lots_cancel(osv.osv): _description = 'To cancel auction lots.' def _cancel(self, cr, uid, ids, context): - """ - To cancel the auction lot + """ + To cancel the auction lot + + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: List of IDs selected + @param context: A standard dictionary + @return: + """ - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: List of IDs selected - @param context: A standard dictionary - @return: - """ - - lots_obj = self.pool.get('auction.lots') - invoice_obj = self.pool.get('account.invoice') - lot = lots_obj.browse(cr,uid,context['active_id'],context) - if lot.ach_inv_id: - p = invoice_obj.refund(['lot.ach_inv_id.id'],context) - if lot.vnd_inv_id: - p = invoice_obj.refund(['lot.vnd_inv_id.id'],context) - return {} + lots_obj = self.pool.get('auction.lots') + invoice_obj = self.pool.get('account.invoice') + lot = lots_obj.browse(cr,uid,context['active_id'],context) + if lot.ach_inv_id: + p = invoice_obj.refund(['lot.ach_inv_id.id'],context) + if lot.vnd_inv_id: + p = invoice_obj.refund(['lot.vnd_inv_id.id'],context) + return {} _columns = { diff --git a/addons/auction/wizard/auction_transfer_unsold_object.py b/addons/auction/wizard/auction_transfer_unsold_object.py new file mode 100644 index 00000000000..fcc623f3cdd --- /dev/null +++ b/addons/auction/wizard/auction_transfer_unsold_object.py @@ -0,0 +1,90 @@ +# -*- 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 . +# +############################################################################## + +from osv import osv +from osv import fields + +class auction_transfer_unsold_object(osv.osv): + ''' + Open ERP Model + ''' + _name = 'auction.transfer.unsold.object' + _description = 'To transfer unsold objects' + + def _start(self, cr, uid, ids, context): + """ + To initialize auction_id_from + + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: List of IDs selected + @param context: A standard dictionary + @return: auction_id_from + """ + lots_obj = self.pool.get('auction.lots') + rec = lots_obj.browse(cr, uid, context['active_id'], context) + auction_from = rec and rec.auction_id.id or False + return {'auction_id_from': auction_from} + + def transfer_unsold_object(self, cr, uid, ids, context): + """ + To Transfer the unsold object + + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: List of IDs selected + @param context: A standard dictionary + @return: + + """ + bid_line_obj = self.pool.get('auction.bid_line') + lots_obj = self.pool.get('auction.lots') + lot_history_obj = self.pool.get('auction.lot.history') + line_ids= bid_line_obj.search(cr,uid,[('lot_id','in',context['active_ids'])]) + bid_line_obj.unlink(cr, uid, line_ids) + + res = self.browse(cr, uid, ids) + + unsold_ids = lots_obj.search(cr,uid,[('auction_id','=',res[0].auction_id_from),('state','=','unsold')]) + for rec in lots_obj.browse(cr, uid, unsold_ids, context): + new_id = lot_history_obj.create(cr,uid,{'auction_id':rec.auction_id.id,'lot_id':rec.id,'price': rec.obj_ret, 'name': 'reasons'+rec.auction_id.auction1}) + up_auction = lots_obj.write(cr,uid,[rec.id],{'auction_id': res[0].auction_id_to, + 'obj_ret':None, + 'obj_price':None, + 'ach_login':None, + 'ach_uid':None, + 'ach_inv_id':None, + 'sel_inv_id':None, + 'state':'draft'}) + + return {} + + _columns = { + 'auction_id_from':fields.many2one('auction.dates', 'From Auction Date', required=True), + 'auction_id_to':fields.many2one('auction.dates', 'To Auction Date', required=True), + } + + _defaults = { + 'auction_id_from': lambda *a: _start, + } +auction_transfer_unsold_object() \ No newline at end of file diff --git a/addons/auction/wizard/auction_transfer_unsold_object_view.xml b/addons/auction/wizard/auction_transfer_unsold_object_view.xml new file mode 100644 index 00000000000..33c3c2007ed --- /dev/null +++ b/addons/auction/wizard/auction_transfer_unsold_object_view.xml @@ -0,0 +1,33 @@ + + + + + auction.transfer.unsold.object.form + auction.transfer.unsold.object + form + +
+ + + + + + + +