~willowit-openerp-team/willowit-openerp-addons/development

« back to all changes in this revision

Viewing changes to auction/wizard/wizard_lots_cancel.py

  • Committer: Deepak Seshadri
  • Date: 2011-04-04 07:04:07 UTC
  • Revision ID: deepak@willowit.com.au-20110404070407-8j9mnxzzgh53o24t
Remove irrelevant modules from this branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#    
4
 
#    OpenERP, Open Source Management Solution
5
 
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6
 
#
7
 
#    This program is free software: you can redistribute it and/or modify
8
 
#    it under the terms of the GNU Affero General Public License as
9
 
#    published by the Free Software Foundation, either version 3 of the
10
 
#    License, or (at your option) any later version.
11
 
#
12
 
#    This program is distributed in the hope that it will be useful,
13
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
#    GNU Affero General Public License for more details.
16
 
#
17
 
#    You should have received a copy of the GNU Affero General Public License
18
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
19
 
#
20
 
##############################################################################
21
 
 
22
 
import wizard
23
 
import netsvc
24
 
import pooler
25
 
 
26
 
paid_form = '''<?xml version="1.0"?>
27
 
<form string="Cancel Payment">
28
 
    <label string="Are you sure you want to refund this invoice ?"/>
29
 
</form>'''
30
 
fields_ask = {
31
 
}
32
 
#
33
 
#def _get_value(self,cr,uid, datas,context={}):
34
 
##  service = netsvc.LocalService("object_proxy")
35
 
#   lots=pool.get('auction.lots').browse(cr,uid,data['id'],context)
36
 
#
37
 
#   
38
 
##  lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', datas['ids'])
39
 
#
40
 
#   ids = []
41
 
#   pay_ids = {}
42
 
#   price = 0.0
43
 
#   price_paid = 0.0
44
 
#   uid = False
45
 
#
46
 
##TODO: refuse if several payments?
47
 
#   for lot in lots:
48
 
#           price += lot['obj_price']
49
 
#
50
 
#           # add all the buyer costs
51
 
#           costs = service.execute(cr.dbname,uid, 'auction.lots', 'compute_buyer_costs', [lot['id']])
52
 
#           for cost in costs:
53
 
#               price += cost['amount']
54
 
#
55
 
##TODO: pr bien faire, faudrait leur poser la question: continue anyway?
56
 
#   if len(ids)<len(datas['ids']):
57
 
#       raise wizard.except_wizard('UserError', ('Some object(s) are not paid !', 'init'))
58
 
#
59
 
#   return {'objects':len(ids), 'amount_total':price, 'amount_paid':price_paid}
60
 
#
61
 
#def _cancel(self, uid, datas):
62
 
#   service = netsvc.LocalService("object_proxy")
63
 
#   lots = service.execute(cr.dbname,uid, 'auction.lots', 'lots_cancel_payment', datas['ids'])
64
 
#   return {}
65
 
#
66
 
 
67
 
def _cancel(self,cr,uid,data,context):
68
 
    pool = pooler.get_pool(cr.dbname)
69
 
    lot = pool.get('auction.lots').browse(cr,uid,data['id'],context)
70
 
    if lot.ach_inv_id:
71
 
        p=pool.get('account.invoice').refund(['lot.ach_inv_id.id'],context)
72
 
    if lot.vnd_inv_id:
73
 
        p=pool.get('account.invoice').refund(['lot.vnd_inv_id.id'],context)
74
 
    return {}
75
 
 
76
 
class wiz_auc_lots_cancel(wizard.interface):
77
 
    states = {
78
 
        'init': {
79
 
            'actions': [],
80
 
            'result': {'type': 'form', 'arch':paid_form, 'fields': fields_ask, 'state':[('make_cancel','Cancel Payment'), ('end','Cancel')]}
81
 
        },
82
 
        'make_cancel': {
83
 
            'actions': [_cancel],
84
 
            'result': {'type': 'state', 'state':'end'}
85
 
        }
86
 
    }
87
 
wiz_auc_lots_cancel('auction.lots.cancel');
88
 
 
89
 
 
90
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
91