~account-core-editors/account-analytic/github-7.0

« back to all changes in this revision

Viewing changes to hr_expense_analytic_plans/model/hr_expense_analytic_plans.py

  • Committer: Alexandre Fayolle
  • Author(s): Pedro M. Baeza
  • Date: 2014-06-26 10:31:24 UTC
  • mfrom: (17.1.1)
  • Revision ID: git-v1:8a6fedb1fd2913bd4a99ef49c48b33a52c1a5ba4
[MRG] add hr_expense_analytic_plans

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution
 
5
#    Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
 
6
#                       Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>
 
7
#
 
8
#    This program is free software: you can redistribute it and/or modify
 
9
#    it under the terms of the GNU Affero General Public License as
 
10
#    published by the Free Software Foundation, either version 3 of the
 
11
#    License, or (at your option) any later version.
 
12
#
 
13
#    This program is distributed in the hope that it will be useful,
 
14
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
#    GNU Affero General Public License for more details.
 
17
#
 
18
#    You should have received a copy of the GNU Affero General Public License
 
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
#
 
21
##############################################################################
 
22
 
 
23
from openerp.osv import fields, orm
 
24
 
 
25
class HrExpenseExpense(orm.Model):
 
26
    _inherit = 'hr.expense.expense'
 
27
 
 
28
    def line_get_convert(self, cr, uid, x, part, date, context=None):
 
29
        res = super(HrExpenseExpense, self).line_get_convert(cr, uid, x, part,
 
30
                                                             date,
 
31
                                                             context=context)
 
32
        res['analytics_id'] = x.get('analytics_id', False)
 
33
        return res
 
34
 
 
35
    def move_line_get_item(self, cr, uid, line, context=None):
 
36
        res = super(HrExpenseExpense, self).move_line_get_item(cr, uid, line,
 
37
                                                               context=context)
 
38
        if line.analytics_id:
 
39
            res['analytics_id'] = line.analytics_id.id
 
40
        return res
 
41
 
 
42
 
 
43
class HrExpenseLine(orm.Model):
 
44
    _inherit = 'hr.expense.line'
 
45
    _columns = {
 
46
        'analytics_id': fields.many2one('account.analytic.plan.instance',
 
47
                                        'Analytic distribution'),
 
48
    }
 
49