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):
30 _name = "auction.lots.make.invoice"
31 _description = "Make invoice"
34 'amount': fields.float('Invoiced Amount', required =True, readonly=True, help="Seller Price"),
35 'objects':fields.integer('# of objects', required =True, readonly=True),
36 'number':fields.char('Invoice Number', size=64),
40 'number': lambda *a: False,
43 def default_get(self, cr, uid, fields, context=None):
45 To get default values for the object.
46 @param self: The object pointer.
47 @param cr: A database cursor
48 @param uid: ID of the user currently logged in
49 @param fields: List of fields for which we want default values
50 @param context: A standard dictionary
51 @return: A dictionary which of fields with values.
55 res = super(auction_lots_make_invoice, self).default_get(cr, uid, fields, context=context)
56 lots_obj = self.pool.get('auction.lots')
57 for lot in lots_obj.browse(cr, uid, context.get('active_ids', []), context=context):
58 if 'amount' in fields:
59 res.update({'amount': lot.seller_price})
60 if 'objects' in fields:
61 res.update({'objects': len(context.get('active_ids', []))})
64 def makeInvoices(self, cr, uid, ids, context=None):
66 Seller invoice :Create an invoice.
67 @param cr: the current row, from the database cursor.
68 @param uid: the current user’s ID for security checks.
69 @param ids: List of Auction lots make invoice’s IDs
70 @return: dictionary of account invoice form.
74 order_obj = self.pool.get('auction.lots')
75 mod_obj = self.pool.get('ir.model.data')
76 result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
77 id = mod_obj.read(cr, uid, result, ['res_id'])
78 lots_ids = order_obj.seller_trans_create(cr, uid, context.get('active_ids', []), context=context)
80 'domain': "[('id','in', ["+','.join(map(str, lots_ids))+"])]",
81 'name': 'Seller invoices',
83 'view_mode': 'tree,form',
84 'res_model': 'account.invoice',
86 'context': "{'type':'out_refund'}",
87 'type': 'ir.actions.act_window',
88 'search_view_id': id['res_id']
91 auction_lots_make_invoice()
93 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: