2010-03-10 13:41:56 +00:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
##############################################################################
|
|
|
|
|
#
|
|
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
|
|
|
#
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
#
|
|
|
|
|
##############################################################################
|
|
|
|
|
from osv import fields, osv
|
|
|
|
|
from tools.translate import _
|
|
|
|
|
import netsvc
|
|
|
|
|
import pooler
|
|
|
|
|
import time
|
|
|
|
|
import tools
|
|
|
|
|
import wizard
|
|
|
|
|
|
|
|
|
|
class auction_lots_make_invoice(osv.osv_memory):
|
2010-04-05 10:14:12 +00:00
|
|
|
|
_name = "auction.lots.make.invoice"
|
|
|
|
|
_description = "Make invoice"
|
2010-03-10 13:41:56 +00:00
|
|
|
|
|
2010-04-05 10:14:12 +00:00
|
|
|
|
_columns = {
|
2010-08-05 10:26:19 +00:00
|
|
|
|
'amount': fields.float('Invoiced Amount', required =True, readonly=True, help="Seller Price"),
|
2010-04-05 10:14:12 +00:00
|
|
|
|
'objects':fields.integer('# of objects', required =True, readonly=True),
|
|
|
|
|
'number':fields.char('Invoice Number', size=64),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_defaults = {
|
|
|
|
|
'number': lambda *a: False,
|
|
|
|
|
}
|
2010-03-18 06:10:48 +00:00
|
|
|
|
|
2010-08-02 12:11:25 +00:00
|
|
|
|
def default_get(self, cr, uid, fields, context=None):
|
2010-03-18 06:10:48 +00:00
|
|
|
|
"""
|
2010-04-05 10:14:12 +00:00
|
|
|
|
To get default values for the object.
|
|
|
|
|
@param self: The object pointer.
|
|
|
|
|
@param cr: A database cursor
|
|
|
|
|
@param uid: ID of the user currently logged in
|
|
|
|
|
@param fields: List of fields for which we want default values
|
|
|
|
|
@param context: A standard dictionary
|
|
|
|
|
@return: A dictionary which of fields with values.
|
2010-03-18 06:10:48 +00:00
|
|
|
|
"""
|
2010-11-23 07:05:05 +00:00
|
|
|
|
if context is None:
|
2010-08-02 12:11:25 +00:00
|
|
|
|
context={}
|
|
|
|
|
res = super(auction_lots_make_invoice, self).default_get(cr, uid, fields, context=context)
|
|
|
|
|
lots_obj = self.pool.get('auction.lots')
|
2010-11-19 13:48:01 +00:00
|
|
|
|
for lot in lots_obj.browse(cr, uid, context.get('active_ids', []), context=context):
|
2010-03-18 09:57:15 +00:00
|
|
|
|
if 'amount' in fields:
|
2010-08-03 10:28:59 +00:00
|
|
|
|
res.update({'amount': lot.seller_price})
|
2010-03-18 09:57:15 +00:00
|
|
|
|
if 'objects' in fields:
|
2010-08-02 12:11:25 +00:00
|
|
|
|
res.update({'objects': len(context.get('active_ids', []))})
|
2010-03-18 09:57:15 +00:00
|
|
|
|
return res
|
2010-03-10 13:41:56 +00:00
|
|
|
|
|
2010-08-02 12:11:25 +00:00
|
|
|
|
def makeInvoices(self, cr, uid, ids, context=None):
|
2010-03-10 13:41:56 +00:00
|
|
|
|
"""
|
2010-04-05 10:14:12 +00:00
|
|
|
|
Seller invoice :Create an invoice.
|
2010-03-10 13:41:56 +00:00
|
|
|
|
@param cr: the current row, from the database cursor.
|
|
|
|
|
@param uid: the current user’s ID for security checks.
|
|
|
|
|
@param ids: List of Auction lots make invoice’s IDs
|
|
|
|
|
@return: dictionary of account invoice form.
|
2010-03-15 12:18:15 +00:00
|
|
|
|
"""
|
2010-11-23 07:05:05 +00:00
|
|
|
|
if context is None:
|
2010-08-02 12:11:25 +00:00
|
|
|
|
context={}
|
2010-03-15 12:18:15 +00:00
|
|
|
|
order_obj = self.pool.get('auction.lots')
|
|
|
|
|
mod_obj = self.pool.get('ir.model.data')
|
2010-04-05 10:14:12 +00:00
|
|
|
|
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
|
|
|
|
|
id = mod_obj.read(cr, uid, result, ['res_id'])
|
2010-11-19 13:48:01 +00:00
|
|
|
|
lots_ids = order_obj.seller_trans_create(cr, uid, context.get('active_ids', []), context=context)
|
2010-04-05 10:14:12 +00:00
|
|
|
|
return {
|
|
|
|
|
'domain': "[('id','in', ["+','.join(map(str, lots_ids))+"])]",
|
|
|
|
|
'name': 'Seller invoices',
|
|
|
|
|
'view_type': 'form',
|
|
|
|
|
'view_mode': 'tree,form',
|
|
|
|
|
'res_model': 'account.invoice',
|
|
|
|
|
'view_id': False,
|
|
|
|
|
'context': "{'type':'out_refund'}",
|
|
|
|
|
'type': 'ir.actions.act_window',
|
|
|
|
|
'search_view_id': id['res_id']
|
|
|
|
|
}
|
2010-03-10 13:41:56 +00:00
|
|
|
|
|
|
|
|
|
auction_lots_make_invoice()
|
2011-11-22 08:51:38 +00:00
|
|
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|