SyntaxError: invalid syntax - python 2.7 - Odoo v9 community
<p>I have this code which checks if there's a provider specified, and a pem key, in order to send over an xml to a server:</p>

<pre><code> @api.multi
def send_xml_file(self, envio_dte=None, file_name="envio",company_id=False):
    if not company_id.dte_service_provider:
        raise UserError(_("Not Service provider selected!"))
    try:
        signature_d = self.get_digital_signature_pem(
            company_id)
        seed = self.get_seed(company_id)
        template_string = self.create_template_seed(seed)
        seed_firmado = self.sign_seed(
            template_string, signature_d['priv_key'],
            signature_d['cert'])
        token = self.get_token(seed_firmado,company_id)
    _logger.info(_("Token is: {}").format(token))
    except:
        raise Warning(connection_status[response.e])
        return {'sii_result': 'NoEnviado'}
</code></pre>

<p>On this line: <code>_logger.info(_("Token is: {}").format(token))</code> is throwing me <code>SyntaxError: invalid syntax</code> this is my traceback:</p>

<pre><code>Traceback (most recent call last):
File "/home/kristian/.virtualenvs/odoov9/lib/python2.7/site-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/home/kristian/.virtualenvs/odoov9/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/service/server.py", line 246, in app
return self.app(e, s)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/service/wsgi_server.py", line 184, in application
return application_unproxied(environ, start_response)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/service/wsgi_server.py", line 170, in application_unproxied
result = handler(environ, start_response)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 1492, in __call__
self.load_addons()
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 1513, in load_addons
m = __import__('openerp.addons.' + module)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/modules/module.py", line 61, in load_module
mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)
File "/home/kristian/odoov9/solti/l10n_cl_dte/__init__.py", line 2, in &lt;module&gt;
from . import models, controllers, wizard
File "/home/kristian/odoov9/solti/l10n_cl_dte/models/__init__.py", line 2, in &lt;module&gt;
from . import invoice, partner, company, payment_term, sii_regional_offices
File "/home/kristian/odoov9/solti/l10n_cl_dte/models/invoice.py", line 500
_logger.info(_("Token is: {}").format(token))
      ^
SyntaxError: invalid syntax
</code></pre>

<p>I've checked for missing parenthesis, and stuff like that, but I still cannot figure it out.</p>

<p>Any ideas on this?</p>

<p>Thanks in advance!</p>

<p>Logger needs to be tabbed over, to be in the try block.</p>

<pre><code>@api.multi
def send_xml_file(self, envio_dte=None, file_name="envio",company_id=False):
    if not company_id.dte_service_provider:
        raise UserError(_("Not Service provider selected!"))
    try:
        signature_d = self.get_digital_signature_pem(
            company_id)
        seed = self.get_seed(company_id)
        template_string = self.create_template_seed(seed)
        seed_firmado = self.sign_seed(
            template_string, signature_d['priv_key'],
            signature_d['cert'])
        token = self.get_token(seed_firmado,company_id)
        _logger.info(_("Token is: {}").format(token))
    except:
        # This is probably not doing what you expect
        # raise will stop program execution, so the 
        # return will not actually return.
        raise Warning(connection_status[response.e])
        return {'sii_result': 'NoEnviado'}
</code></pre>

python logging openerp odoo-9