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

« back to all changes in this revision

Viewing changes to account_pain/wizard/pain_wizard.py

  • Committer: root
  • Date: 2012-06-25 19:57:50 UTC
  • Revision ID: root@oerp61-20120625195750-uh3hw9skkfnrt26f
update account_pain

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) 2011 Noviat nv/sa (www.noviat.be). All rights reserved.
 
6
#    Copyright (c) 2012 Noviat nv/sa (www.noviat.be). 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
28
28
from lxml import etree
29
29
import tools
30
30
from tools.translate import _
31
 
import netsvc
32
 
logger=netsvc.Logger()
 
31
import logging
 
32
_logger = logging.getLogger(__name__)
33
33
 
34
34
from operator import itemgetter
35
35
class account_move_line(osv.osv):
114
114
        line_ids = line_obj.search(cr, uid, domain, context=context)
115
115
        context.update({'line_ids': line_ids})
116
116
        model_data_ids = mod_obj.search(cr, uid,[('model', '=', 'ir.ui.view'), ('name', '=', 'view_create_payment_order_lines')], context=context)
117
 
        resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
118
 
        #logger.notifyChannel('addons.'+self._name, netsvc.LOG_WARNING, 'context =  %s' % context )         
 
117
        resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']  
119
118
        return {'name': _('Populate Payment'),
120
119
                'context': context,
121
120
                'view_type': 'form',
130
129
    add context to 'entries' field for use in account.move.line
131
130
    """
132
131
    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
 
132
        _logger.warn('payment.order.create, fields_view_get, before super, context = %s', context)
133
133
        res = super(payment_order_create, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
 
134
        _logger.warn('payment.order.create, fields_view_get, after super, context = %s', context)
 
135
        _logger.warn('payment.order.create, fields_view_get, res = %s', res)
134
136
        if context and 'line_ids' in context:
135
137
            view_obj = etree.XML(res['arch'])
136
138
            for child in view_obj:
359
361
                Amt = etree.SubElement(CdtTrfTxInf, 'Amt')
360
362
                InstdAmt = etree.SubElement(Amt, 'InstdAmt', Ccy='EUR')
361
363
                InstdAmt.text = '%.2f' % line.amount
362
 
                if line.bank_id.iban[0:2].upper() != 'BE' and not line.bank_id.bank.bic:
363
 
                    raise osv.except_osv(_('Configuration Error!'),
364
 
                       _('Unsupported Payment Instruction in Payment Line %s.\n'    \
365
 
                         'Please fill in the BIC code of the Bank Creditor Account for this Payment Line!') % line.name)
366
 
                if line.bank_id.bank.bic:
 
364
                if line.bank_id.iban[0:2].upper() != 'BE':
367
365
                    CdtrAgt = etree.SubElement(CdtTrfTxInf, 'CdtrAgt')
 
366
                    if not line.bank_id.bank.bic:
 
367
                        raise osv.except_osv(_('Configuration Error!'),
 
368
                           _('Unsupported Payment Instruction in Payment Line %s.\n'    \
 
369
                             'Please fill in the BIC code of the Bank Creditor Account for this Payment Line!') % line.name)
368
370
                    FinInstnId = etree.SubElement(CdtrAgt, 'FinInstnId')
369
371
                    BIC = etree.SubElement(FinInstnId, 'BIC')
370
 
                    BIC.text = line.bank_id.bank.bic.replace(' ','')
 
372
                    BIC.text = line.bank_id.bank.bic
371
373
                Cdtr = etree.SubElement(CdtTrfTxInf, 'Cdtr')
372
374
                Nm = etree.SubElement(Cdtr, 'Nm')
373
375
                Nm.text = line.partner_id.name
421
423
                }, context=context)
422
424
            payment_obj.set_done(cr, uid, [active_id], context)
423
425
        else:
424
 
            logger.notifyChannel('addons.'+self._name, netsvc.LOG_ERROR, 'The generated XML file does not fit the required schema !') 
425
 
            logger.notifyChannel('addons.'+self._name, netsvc.LOG_ERROR, tools.ustr(xmlschema.error_log.last_error))        
 
426
            _logger.error('The generated XML file does not fit the required schema !')
 
427
            _logger.error(tools.ustr(xmlschema.error_log.last_error))
426
428
            error = xmlschema.error_log[0]
427
429
            raise osv.except_osv(_('The generated XML file does not fit the required schema !'),
428
430
                error.message)