1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
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.
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.
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/>.
20 ##############################################################################
21 from osv import fields, osv
22 from tools.translate import _
29 class auction_lots_make_invoice(osv.osv_memory):
32 def default_get(self, cr, uid, fields, context):
34 To get default values for the object.
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
42 @return: A dictionary which of fields with values.
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'])})
54 def makeInvoices(self, cr, uid, ids, context):
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.
62 order_obj = self.pool.get('auction.lots')
63 mod_obj = self.pool.get('ir.model.data')
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'])
69 ids = order_obj.seller_trans_create(cr, uid, context['active_ids'], context)
72 'domain': "[('id','in', ["+','.join(map(str, ids))+"])]",
73 'name': 'Seller invoices',
75 'view_mode': 'tree,form',
76 'res_model': 'account.invoice',
78 'context': "{'type':'out_refund'}",
79 'type': 'ir.actions.act_window',
80 'search_view_id': id['res_id']
83 _name = "auction.lots.make.invoice"
84 _description = "Make invoice"
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),
92 'number':lambda *a: False,
96 auction_lots_make_invoice()