[FIX] auction: auction_transfer_unsold_object issues has been fixed
[odoo/odoo.git] / addons / auction / wizard / auction_lots_make_invoice.py
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 from osv import fields, osv
22 from tools.translate import _
23 import netsvc
24 import pooler
25 import time
26 import tools
27 import wizard
28
29 class auction_lots_make_invoice(osv.osv_memory):
30     
31     
32     def default_get(self, cr, uid, fields, context):
33         """ 
34               To get default values for the object.
35             
36              @param self: The object pointer.
37              @param cr: A database cursor
38              @param uid: ID of the user currently logged in
39              @param fields: List of fields for which we want default values 
40              @param context: A standard dictionary 
41              
42              @return: A dictionary which of fields with values. 
43         
44         """        
45         res = super(auction_lots_make_invoice, self).default_get(cr, uid, fields, context=context) 
46         for lot in self.pool.get('auction.lots').browse(cr, uid, context.get('active_ids', [])):
47             if 'amount' in fields:
48                 res.update({'amount': lot.buyer_price})                
49             if 'objects' in fields:
50                 res.update({'objects': len(context['active_ids'])})   
51         return res               
52
53     
54     def makeInvoices(self, cr, uid, ids, context):
55         """
56         seller invoice :Create an invoice.
57         @param cr: the current row, from the database cursor.
58         @param uid: the current user’s ID for security checks.
59         @param ids: List of Auction lots make invoice’s IDs
60         @return: dictionary of  account invoice form.
61         """
62         order_obj = self.pool.get('auction.lots')
63         mod_obj = self.pool.get('ir.model.data') 
64     
65         for data in self.read(cr, uid, ids):
66             result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
67             id = mod_obj.read(cr, uid, result, ['res_id'])
68             newinv = []
69             ids = order_obj.seller_trans_create(cr, uid, context['active_ids'], context)
70             cr.commit()
71             return {
72                 'domain': "[('id','in', ["+','.join(map(str, ids))+"])]", 
73                 'name': 'Seller invoices', 
74                 'view_type': 'form', 
75                 'view_mode': 'tree,form', 
76                 'res_model': 'account.invoice', 
77                 'view_id': False, 
78                 'context': "{'type':'out_refund'}", 
79                 'type': 'ir.actions.act_window', 
80                 'search_view_id': id['res_id']        
81                 }
82             
83     _name = "auction.lots.make.invoice"
84     _description = "Make invoice"
85     _columns= {
86                'amount': fields.float('Invoiced Amount', required =True, readonly=True), 
87                'objects':fields.integer('# of objects', required =True, readonly=True), 
88                'number':fields.char('Invoice Number', size=64), 
89               
90                }
91     _defaults={
92                'number':lambda *a: False, 
93                
94                }
95
96 auction_lots_make_invoice()