[IMP] auction: Improve the deafult_get method and clean the code
bzr revid: sbh@tinyerp.com-20100318095715-x3k9r7eh2f09pfjj
This commit is contained in:
parent
7b678a4a1b
commit
722a3a7c93
|
@ -42,16 +42,14 @@ class auction_lots_make_invoice(osv.osv_memory):
|
|||
@return: A dictionary which of fields with values.
|
||||
|
||||
"""
|
||||
res = {}
|
||||
res = super(auction_lots_make_invoice, self).default_get(cr, uid, fields, context=context)
|
||||
record_id = context and context.get('active_id',False)
|
||||
if not record_id:
|
||||
return res
|
||||
res = super(auction_lots_make_invoice, self).default_get(cr, uid, fields, context=context)
|
||||
for lot in self.pool.get('auction.lots').browse(cr, uid, context.get('active_ids', [])):
|
||||
if 'amount' in fields:
|
||||
res.update({'amount': lot.buyer_price})
|
||||
if 'objects' in fields:
|
||||
res.update({'objects': len(context['active_ids'])})
|
||||
return res
|
||||
|
||||
lot= self.pool.get('auction.lots').browse(cr, uid, record_id)
|
||||
res['amount']=lot.buyer_price
|
||||
res['objects'] = len(context['active_ids'])
|
||||
return res
|
||||
|
||||
def makeInvoices(self, cr, uid, ids, context):
|
||||
"""
|
||||
|
|
|
@ -41,16 +41,14 @@ class auction_lots_make_invoice_buyer(osv.osv_memory):
|
|||
@return: A dictionary which of fields with values.
|
||||
|
||||
"""
|
||||
res = {}
|
||||
record_id = context and context.get('active_id',False)
|
||||
res = super(auction_lots_make_invoice_buyer, self).default_get(cr, uid, fields, context=context)
|
||||
if not record_id:
|
||||
return res
|
||||
|
||||
lot= self.pool.get('auction.lots').browse(cr, uid, record_id)
|
||||
res['amount']=lot.buyer_price
|
||||
res['buyer_id']=lot.ach_uid and lot.ach_uid.id or False
|
||||
res['objects'] = len(context['active_ids'])
|
||||
for lot in self.pool.get('auction.lots').browse(cr, uid, context.get('active_ids', [])):
|
||||
if 'amount' in fields:
|
||||
res.update({'amount': lot.buyer_price})
|
||||
if 'buyer_id' in fields:
|
||||
res.update({'buyer_id': lot.ach_uid and lot.ach_uid.id or False})
|
||||
if 'objects' in fields:
|
||||
res.update({'objects': len(context['active_ids'])})
|
||||
return res
|
||||
|
||||
def makeInvoices(self, cr, uid, ids, context):
|
||||
|
|
|
@ -54,7 +54,6 @@ class auction_lots_sms_send(osv.osv_memory):
|
|||
partner_address_obj = self.pool.get('res.partner.address')
|
||||
for datas in self.read(cr, uid, ids):
|
||||
lots = lot_obj.read(cr, uid, context['active_ids'], ['obj_num','obj_price','ach_uid'])
|
||||
print "lots",lots, [l['ach_uid'][0] for l in lots if l['ach_uid']]
|
||||
res = partner_obj.read(cr, uid, [l['ach_uid'][0] for l in lots if l['ach_uid']], ['gsm'], context)
|
||||
|
||||
nbr = 0
|
||||
|
|
|
@ -42,20 +42,14 @@ class auction_pay_buy(osv.osv_memory):
|
|||
@return: A dictionary which of fields with values.
|
||||
|
||||
"""
|
||||
res = {}
|
||||
res = super(auction_pay_buy, self).default_get(cr, uid, fields, context=context)
|
||||
record_id = context and context.get('active_id',False)
|
||||
if not record_id:
|
||||
return res
|
||||
|
||||
lot= self.pool.get('auction.lots').browse(cr, uid, record_id)
|
||||
if lot.is_ok :
|
||||
raise osv.except_osv('Error !', 'Some lots of the selection are already paid.')
|
||||
|
||||
res['amount']=lot.buyer_price
|
||||
res['total']=lot.buyer_price
|
||||
res['buyer_id']=lot.ach_uid and lot.ach_uid.id or False
|
||||
res['objects'] = len(context['active_ids'])
|
||||
res = super(auction_pay_buy, self).default_get(cr, uid, fields, context=context)
|
||||
for lot in self.pool.get('auction.lots').browse(cr, uid, context.get('active_ids', [])):
|
||||
if 'amount' in fields:
|
||||
res.update({'amount': lot.buyer_price})
|
||||
if 'buyer_id' in fields:
|
||||
res.update({'buyer_id': lot.ach_uid and lot.ach_uid.id or False})
|
||||
if 'total' in fields:
|
||||
res.update({'total': lot.buyer_price})
|
||||
return res
|
||||
|
||||
def pay_and_reconcile(self, cr, uid, ids, context):
|
||||
|
|
Loading…
Reference in New Issue