2009-10-13 05:58:37 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-08-24 14:45:43 +00:00
|
|
|
##############################################################################
|
2010-06-01 10:01:37 +00:00
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
2010-01-12 09:18:39 +00:00
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
2008-08-24 14:45:43 +00:00
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2009-10-14 11:15:34 +00:00
|
|
|
# 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.
|
2008-08-24 14:45:43 +00:00
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
# 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
|
2009-10-14 11:15:34 +00:00
|
|
|
# GNU Affero General Public License for more details.
|
2008-08-24 14:45:43 +00:00
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
2010-06-01 10:01:37 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-08-24 14:45:43 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import fields, osv
|
2008-08-24 14:45:43 +00:00
|
|
|
|
2010-06-01 10:01:37 +00:00
|
|
|
class invoice_directly(osv.osv_memory):
|
|
|
|
_inherit = 'stock.partial.picking'
|
2008-08-24 14:45:43 +00:00
|
|
|
|
2010-11-22 10:37:53 +00:00
|
|
|
def do_partial(self, cr, uid, ids, context=None):
|
2011-09-26 00:36:12 +00:00
|
|
|
"""Launch Create invoice wizard if invoice state is To be Invoiced,
|
|
|
|
after processing the partial picking.
|
2010-08-03 05:38:30 +00:00
|
|
|
"""
|
2011-09-26 00:36:12 +00:00
|
|
|
if context is None: context = {}
|
2010-06-01 10:01:37 +00:00
|
|
|
result = super(invoice_directly, self).do_partial(cr, uid, ids, context)
|
2011-09-26 00:36:12 +00:00
|
|
|
partial = self.browse(cr, uid, ids[0], context)
|
2013-10-23 15:13:42 +00:00
|
|
|
if partial.picking_id.state != 'done' and partial.picking_id.backorder_id:
|
|
|
|
# delivery is not finished, opening invoice on backorder
|
|
|
|
picking = partial.picking_id.backorder_id
|
|
|
|
else:
|
|
|
|
picking = partial.picking_id
|
2011-09-26 00:36:12 +00:00
|
|
|
context.update(active_model='stock.picking',
|
2013-10-23 15:13:42 +00:00
|
|
|
active_ids=[picking.id])
|
|
|
|
if picking.invoice_state == '2binvoiced':
|
2010-06-01 10:01:37 +00:00
|
|
|
return {
|
|
|
|
'name': 'Create Invoice',
|
|
|
|
'view_type': 'form',
|
|
|
|
'view_mode': 'form',
|
|
|
|
'res_model': 'stock.invoice.onshipping',
|
|
|
|
'type': 'ir.actions.act_window',
|
|
|
|
'target': 'new',
|
2011-03-28 10:04:38 +00:00
|
|
|
'context': context
|
2010-08-03 05:38:30 +00:00
|
|
|
}
|
2010-12-28 10:41:38 +00:00
|
|
|
return {'type': 'ir.actions.act_window_close'}
|
2008-08-24 14:45:43 +00:00
|
|
|
|
2010-06-01 10:01:37 +00:00
|
|
|
invoice_directly()
|
2008-08-24 14:45:43 +00:00
|
|
|
|
2012-03-05 18:40:03 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|