~pedro.baeza/account-consolidation/7.0-translation-template-files

« back to all changes in this revision

Viewing changes to account_consolidation/account_move_line.py

[MRG] bug fixes for lp:1149429 and lp:1133189

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    Author: Nicolas Bessi Guewen Baconnier
 
5
#    Copyright 2011-2013 Camptocamp SA
 
6
#
 
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.
 
11
#
 
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.
 
16
#
 
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/>.
 
19
#
 
20
##############################################################################
 
21
 
 
22
from openerp.osv import orm, fields
 
23
 
 
24
 
 
25
class AccountMoveLine(orm.Model):
 
26
    _inherit = 'account.move.line'
 
27
 
 
28
    def _current_company(self, cursor, uid, ids, name, args, context=None):
 
29
        company_id = self.pool['res.company']._company_default_get(cursor, uid)
 
30
        curr_ids = self.search(cursor, uid, [('company_id', '=', company_id)])
 
31
        res = dict([(tid, tid in curr_ids) for tid in ids])
 
32
        return res
 
33
 
 
34
 
 
35
    def search_is_current_company(self, cursor, uid, obj, name, args, context=None):
 
36
        company_id = self.pool['res.company']._company_default_get(cursor, uid)
 
37
        res = self.search(cursor, uid, [('company_id', '=', company_id)])
 
38
        return [('id', 'in', res)]
 
39
 
 
40
    _columns = {'consol_company_id': fields.related('move_id', 'consol_company_id',
 
41
                                                    relation='res.company',
 
42
                                                    type="many2one",
 
43
                                                    string='Subsidaries',
 
44
                                                    store=True,  # for the group_by
 
45
                                                    readonly=True),
 
46
 
 
47
                'is_current_company': fields.function(_current_company,
 
48
                                                      string="Current company",
 
49
                                                      type="boolean",
 
50
                                                      fnct_search=search_is_current_company)
 
51
                }