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

« back to all changes in this revision

Viewing changes to account_coda_pain/wizard/account_coda_import.py

  • Committer: Luc De Meyer
  • Date: 2014-08-29 15:19:39 UTC
  • Revision ID: luc.demeyer@noviat.com-20140829151939-vqscyplor81jj4al
update noviat modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#
4
4
#    OpenERP, Open Source Management Solution
5
5
#
6
 
#    Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
 
6
#    Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
7
7
#
8
8
#    This program is free software: you can redistribute it and/or modify
9
9
#    it under the terms of the GNU Affero General Public License as
12
12
#
13
13
#    This program is distributed in the hope that it will be useful,
14
14
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
16
#    GNU Affero General Public License for more details.
17
17
#
18
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/>.
 
19
#    along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
#
21
21
##############################################################################
22
22
 
23
 
from osv import osv
24
 
from tools.translate import _
25
 
#import logging
26
 
#_logger = logging.getLogger(__name__)
27
 
 
28
 
class account_coda_import(osv.osv_memory):
 
23
from openerp.osv import orm
 
24
from openerp.tools.translate import _
 
25
 
 
26
 
 
27
class account_coda_import(orm.TransientModel):
29
28
    _inherit = 'account.coda.import'
30
29
 
 
30
    def _st_line_hook(self, cr, uid, coda_bank_params, line, st_line_vals, context=None):
 
31
        if line.get('payment_line_id'):
 
32
            st_line_vals['payment_line_id'] = line['payment_line_id']
 
33
        return super(account_coda_import, self)._st_line_hook(cr, uid, coda_bank_params, line, st_line_vals, context=context)
 
34
 
31
35
    def _match_payment_reference(self, cr, uid, st_line, coda_parsing_note, coda_statement, context=None):
32
36
        """ check payment reference in bank statement line against payment order lines """
33
37
        payment_line_obj = self.pool.get('payment.line')
34
38
        coda_bank_params = coda_statement['coda_bank_params']
35
39
        find_payment = coda_bank_params['find_payment']
36
40
        match={}
37
 
        
 
41
 
38
42
        payment_reference = st_line['payment_reference']
39
43
        if payment_reference and find_payment and st_line['amount'] < 0:
40
44
            payline_ids = payment_line_obj and payment_line_obj.search(cr, uid, [('name', '=', payment_reference)])
42
46
                if len(payline_ids) == 1:
43
47
                    payline = payment_line_obj.browse(cr, uid, payline_ids[0], context=context)
44
48
                    match['payment_line_id'] = payline.id
 
49
                    st_line['payment_line_id'] = payline.id
45
50
                    st_line['partner_id'] = payline.partner_id.id
46
51
                    if payline.move_line_id:
47
52
                        st_line['reconcile'] = payline.move_line_id.id
48
53
                        st_line['account_id'] = payline.move_line_id.account_id.id
49
 
                        st_line['type'] = payline.move_line_id.account_id.type == 'receivable' and 'customer' or 'supplier' 
 
54
                        st_line['type'] = payline.move_line_id.account_id.type == 'receivable' and 'customer' or 'supplier'
50
55
                else:
51
56
                    err_string = _('\nThe CODA parsing detected a payment reference ambiguity while processing movement data record 2.3, seq nr %s!'    \
52
 
                        '\nPlease check your Payment Gateway configuration or contact your OpenERP support channel.') % line[2:10]                   
 
57
                        '\nPlease check your Payment Gateway configuration or contact your OpenERP support channel.') % line[2:10]
53
58
                    err_code = 'R2007'
54
59
                    if self.batch:
55
60
                        return (err_code, err_string)
56
 
                    raise osv.except_osv(_('Error!'), err_string)    
 
61
                    raise orm.except_orm(_('Error!'), err_string)
57
62
 
58
63
        return st_line, coda_parsing_note, match
59
 
        
60
 
account_coda_import()
61
 
        
 
64
 
62
65
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
 
b'\\ No newline at end of file'