~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to split_invoice_button/invoice.py

  • Committer: Tulio Ruiz
  • Date: 2012-02-27 17:31:56 UTC
  • mto: This revision was merged to the branch mainline in revision 130.
  • Revision ID: tulio@vauxoo.com-20120227173156-tv919y7nevf0kbpm
[ADD] Agregado addon que permite ver todas las facturas que se generan al hacer un split

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
###########################################################################
 
3
#    Module Writen to OpenERP, Open Source Management Solution
 
4
#    Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
 
5
#    All Rights Reserved
 
6
###############Credits######################################################
 
7
#    Coded by: nhomar@openerp.com.ve,
 
8
#    Planified by: Nhomar Hernandez
 
9
#    Finance by: Helados Gilda, C.A. http://heladosgilda.com.ve
 
10
#    Audited by: Humberto Arocha humberto@openerp.com.ve
 
11
#############################################################################
 
12
#    This program is free software: you can redistribute it and/or modify
 
13
#    it under the terms of the GNU Affero General Public License as published by
 
14
#    the Free Software Foundation, either version 3 of the License, or
 
15
#    (at your option) any later version.
 
16
#
 
17
#    This program is distributed in the hope that it will be useful,
 
18
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
#    GNU Affero General Public License for more details.
 
21
#
 
22
#    You should have received a copy of the GNU Affero General Public License
 
23
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
24
##############################################################################
 
25
from osv import osv
 
26
from osv import fields
 
27
from tools.translate import _
 
28
import netsvc
 
29
 
 
30
class account_invoice(osv.osv):
 
31
    _inherit = 'account.invoice'
 
32
 
 
33
    def search_asociated_invoice(self, cr, uid, ids, context=None):
 
34
        if context is None:
 
35
            context = {}
 
36
        data_pool = self.pool.get('ir.model.data')
 
37
        inv_type = self.read(cr, uid, ids[0], ['type', 'name'])
 
38
        name = inv_type['name']
 
39
        inv_type = inv_type['type']
 
40
        invoice_ids = self.search(cr, uid, [('name', '=', name)])
 
41
        # inv_type = context.get('inv_type', False)
 
42
        action_model = False
 
43
        action = {}
 
44
        if not invoice_ids:
 
45
            raise osv.except_osv(_('Error'), _('No Invoices were created'))
 
46
        if inv_type == "out_invoice":
 
47
            action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree1")
 
48
        elif inv_type == "in_invoice":
 
49
            action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree2")
 
50
        elif inv_type == "out_refund":
 
51
            action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree3")
 
52
        elif inv_type == "in_refund":
 
53
            action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree4")
 
54
        if action_model:
 
55
            action_pool = self.pool.get(action_model)
 
56
            action = action_pool.read(cr, uid, action_id, context=context)
 
57
            action['domain'] = "[('id','in', ["+','.join(map(str,invoice_ids))+"])]"
 
58
            action.update({'nodestroy': True})
 
59
        return action
 
60
 
 
61
account_invoice()