def _l10n_it_edi_upload(self, files, proxy_user): '''Upload files to fatturapa. :param files: A list of dictionary {filename, base64_xml}. :returns: A dictionary. * message: Message from fatturapa. * transactionId: The fatturapa ID of this request. * error: An eventual error. * error_level: Info, warning, error. ''' ERRORS = { 'EI01': { 'error': _lt('Attached file is empty'), 'blocking_level': 'error' }, 'EI02': { 'error': _lt('Service momentarily unavailable'), 'blocking_level': 'warning' }, 'EI03': { 'error': _lt('Unauthorized user'), 'blocking_level': 'error' }, } result = proxy_user._make_request( proxy_user._get_server_url() + '/api/l10n_it_edi/1/out/SdiRiceviFile', params={'files': files}) # Translate the errors. for filename in result.keys(): if 'error' in result[filename]: result[filename] = ERRORS.get( result[filename]['error'], { 'error': result[filename]['error'], 'blocking_level': 'error' }) return result
# -*- coding: utf-8 -*- import babel.dates import pytz from lxml import etree import base64 import json from flectra import _, _lt, api, fields, models from flectra.osv.expression import AND, TRUE_DOMAIN, normalize_domain from flectra.tools import date_utils, lazy from flectra.tools.misc import get_lang from flectra.exceptions import UserError from collections import defaultdict SEARCH_PANEL_ERROR_MESSAGE = _lt("Too many items to display.") def is_true_domain(domain): return normalize_domain(domain) == TRUE_DOMAIN class lazymapping(defaultdict): def __missing__(self, key): value = self.default_factory(key) self[key] = value return value DISPLAY_DATE_FORMATS = { 'day': 'dd MMM yyyy', 'week': "'W'w YYYY", 'month': 'MMMM yyyy', 'quarter': 'QQQ yyyy',
if not options.get('display_currency'): # search on the model if they are a res.currency field to set as default fields = record._fields.items() currency_fields = [k for k, v in fields if v.type == 'many2one' and v.comodel_name == 'res.currency'] if currency_fields: options['display_currency'] = record[currency_fields[0]] if 'date' not in options: options['date'] = record._context.get('date') if 'company_id' not in options: options['company_id'] = record._context.get('company_id') return super(MonetaryConverter, self).record_to_html(record, field_name, options) TIMEDELTA_UNITS = ( ('year', _lt('year'), 3600 * 24 * 365), ('month', _lt('month'), 3600 * 24 * 30), ('week', _lt('week'), 3600 * 24 * 7), ('day', _lt('day'), 3600 * 24), ('hour', _lt('hour'), 3600), ('minute', _lt('minute'), 60), ('second', _lt('second'), 1) ) class FloatTimeConverter(models.AbstractModel): """ ``float_time`` converter, to display integral or fractional values as human-readable time spans (e.g. 1.5 as "01:30"). Can be used on any numerical field. """
# -*- coding: utf-8 -*- # Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details. import logging import requests from flectra import api, fields, models, _, _lt from flectra.exceptions import UserError _logger = logging.getLogger(__name__) TWITTER_EXCEPTION = { 304: _lt('There was no new data to return.'), 400: _lt('The request was invalid or cannot be otherwise served. Requests without authentication are considered invalid and will yield this response.' ), 401: _lt('Authentication credentials were missing or incorrect. Maybe screen name tweets are protected.' ), 403: _lt('The request is understood, but it has been refused or access is not allowed. Please check your Twitter API Key and Secret.' ), 429: _lt('Request cannot be served due to the applications rate limit having been exhausted for the resource.' ), 500: _lt('Twitter seems broken. Please retry later. You may consider posting an issue on Twitter forums to get help.' ), 502: