~taktik/openobject-addons/hui-extra-6.1

22 by root
update noviat accounting modules
1
# -*- encoding: utf-8 -*-
2
##############################################################################
3
#
4
#    OpenERP, Open Source Management Solution
5
#    
6
#    Copyright (c) 2012 Noviat nv/sa (www.noviat.be). All rights reserved.
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 osv import osv, fields
24
import re
25
from tools.translate import _
26
import logging
27
_logger = logging.getLogger(__name__)
28
29
class account_move_line(osv.osv):
30
    _inherit = 'account.move.line'
31
32
    def reconcile(self, cr, uid, ids, *args, **kwargs):
33
        res = super(account_move_line,self).reconcile(cr, uid, ids, *args, **kwargs)
34
        cfpline_obj = self.pool.get('account.cashflow.provision.line')
35
        for move_line in self.browse(cr, uid, ids):
36
            inv = move_line.invoice
37
            if inv:
38
                domain = [ ('origin', '=', inv._name + ',' + str(inv.id))]
39
                cfpline_ids = cfpline_obj.search(cr, uid, domain)
40
                if len(cfpline_ids) > 1:
41
                    raise osv.except_osv(_('Warning'), _('Cash Flow Provision Line ambiguity, cf. lines %s') % cfpline_ids)
42
                elif len(cfpline_ids) == 1:
43
                    cfpline_obj.write(cr, uid, [cfpline_ids[0]], {'state': 'draft'})            
44
                    cfpline_obj.unlink(cr, uid, [cfpline_ids[0]])  
45
        return res
46
47
account_move_line()