[IMP] auction: wizard_transfer_unsold_object has been converted into osv_memory
bzr revid: mso@mso-20100329073616-4wqbajcfbav81mte
This commit is contained in:
parent
d596d0f1a4
commit
ba26fd5ce3
|
@ -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 = {
|
||||
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
# -*- 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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()
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="name_form" model="ir.ui.view">
|
||||
<field name="name">auction.transfer.unsold.object.form</field>
|
||||
<field name="model">auction.transfer.unsold.object</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Draft To Posted">
|
||||
<group col="1" colspan="2">
|
||||
<separator colspan="4" string="Transfer unsold Object: Current auction date to another " />
|
||||
</group>
|
||||
<newline/>
|
||||
<field name="auction_id_from" select="1"/>
|
||||
<newline/>
|
||||
<field name="auction_id_to" select="1"/>
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="transfer_unsold_object" string="Transfer"
|
||||
colspan="1" type="object" icon="gtk-ok" />
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window name="Draft To Posted"
|
||||
res_model="auction.transfer.unsold.object"
|
||||
src_model=""
|
||||
view_mode="form"
|
||||
target="new"
|
||||
key2="client_action_multi"
|
||||
id="act_auction_lots_cancel"/>
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,92 +0,0 @@
|
|||
# -*- 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 time
|
||||
import wizard
|
||||
import netsvc
|
||||
import pooler
|
||||
from osv.orm import browse_record
|
||||
import sql_db
|
||||
|
||||
transfer_unsold_object_form = """<?xml version="1.0"?>
|
||||
<form string="Draft To Posted">
|
||||
<group col="1" colspan="2">
|
||||
<separator colspan="4" string="Transfer unsold Object: Current auction date to another " />
|
||||
</group>
|
||||
<newline/>
|
||||
<field name="auction_id_from"/>
|
||||
<newline/>
|
||||
<field name="auction_id_to"/>
|
||||
</form>
|
||||
"""
|
||||
|
||||
transfer_unsold_object_fields = {
|
||||
'auction_id_from': {'string':'From Auction Date', 'type':'many2one', 'required':True, 'relation':'auction.dates'},
|
||||
'auction_id_to': {'string':'To Auction Date', 'type':'many2one', 'required':True, 'relation':'auction.dates'},
|
||||
}
|
||||
|
||||
def _start(self,cr,uid,data,context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
rec=pool.get('auction.lots').browse(cr,uid,data['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, data, context):
|
||||
#if not (data['form']['auction_id_to']) :
|
||||
# return {}
|
||||
#Historique de l objet + changement de l auction date + supp des bid line
|
||||
line_ids= pooler.get_pool(cr.dbname).get('auction.bid_line').search(cr,uid,[('lot_id','in',data['ids'])])
|
||||
pooler.get_pool(cr.dbname).get('auction.bid_line').unlink(cr, uid, line_ids)
|
||||
|
||||
obj_pool = pooler.get_pool(cr.dbname).get('auction.lots')
|
||||
ids= obj_pool.search(cr,uid,[('auction_id','=',data['form']['auction_id_from']),('state','=','unsold')])
|
||||
for rec in obj_pool.browse(cr, uid, ids, context):
|
||||
new_id=pooler.get_pool(cr.dbname).get('auction.lot.history').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=pooler.get_pool(cr.dbname).get('auction.lots').write(cr,uid,[rec.id],{'auction_id':data['form']['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'})
|
||||
|
||||
# new_id = self.pool.get('auction.lot.history').copy(cr, uid, m.id, {'price': recs.obj_ret, 'name': 'reasons'+recs.auction_id.name})
|
||||
# new_id=pooler.get_pool(cr.dbname).get('auction.lot.history').create(cr,uid,{'auction_id':rec.auction_id,'lot_id':rec.name,'price': rec.obj_ret, 'name': 'reasons'+rec.auction_id.auction1})
|
||||
return {}
|
||||
|
||||
class transfer_object(wizard.interface):
|
||||
states = {
|
||||
'init' : {
|
||||
'actions' : [_start],
|
||||
'result' : {'type' : 'form',
|
||||
'arch' : transfer_unsold_object_form,
|
||||
'fields' :transfer_unsold_object_fields,
|
||||
'state' : [('transfer', 'Transfer'),('end', 'Cancel') ]}
|
||||
},
|
||||
'transfer' : {
|
||||
'actions' : [_transfer_unsold_object],
|
||||
'result' : {'type' : 'state','state' : 'end'}
|
||||
},
|
||||
}
|
||||
transfer_object('auction.lots.transfer.unsold.object')
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
Loading…
Reference in New Issue