1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Author: Nicolas Bessi Guewen Baconnier
5
# Copyright 2011-2013 Camptocamp SA
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
##############################################################################
22
from openerp.osv import orm, fields
25
class AccountMoveLine(orm.Model):
26
_inherit = 'account.move.line'
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])
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)]
40
_columns = {'consol_company_id': fields.related('move_id', 'consol_company_id',
41
relation='res.company',
44
store=True, # for the group_by
47
'is_current_company': fields.function(_current_company,
48
string="Current company",
50
fnct_search=search_is_current_company)