This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Backport weakref.finalize from Python 3.5, simplified.""" | |
import atexit | |
import sys | |
import weakref | |
class finalize(object): | |
"""Class for finalization of weakrefable objects |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST_TABLE = (0, 9, 4, 6, 8, 2, 7, 1, 3, 5) | |
IBAN_TABLE = dict([(c, str(idx)) | |
for (idx, c) in enumerate('0123456789abcdefgh' | |
'ijklmnopqrstuvwxyz')]) | |
def validate_postaccount(value): | |
"""Check the Post Account.""" | |
if not value: | |
raise ValueError('Post Account cannot be empty') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Example of CSV import usage | |
from openerp import SUPERUSER_ID | |
from openerp.osv.orm import Model, fields | |
from openerp.addons.my_base.openerp_tools import convert_csv_import | |
class BetterZip(Model): | |
"""Zip object.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import absolute_import | |
import contextlib | |
__all__ = ['savepoint', 'create_missing_indexes'] | |
@contextlib.contextmanager | |
def savepoint(cr, name, quiet=False): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
# -*- coding: utf-8 -*- | |
# Adapted from a contribution of @jdahlin on jcrocholl/pep8/pull/230 | |
import collections | |
import multiprocessing | |
import pep8 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
# Helper to check if the name is a valid identifier | |
_isidentifier = re.compile(r'[a-zA-Z_]\w*').match | |
@contextlib.contextmanager | |
def savepoint(cr, name, quiet=False): | |
assert _isidentifier(name) | |
cr.execute('SAVEPOINT "%s";' % name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* /web_mycompany/static/src/css/mycompany.css */ | |
/* Header */ | |
.openerp.production .company_logo { | |
background: url('/web_mycompany/static/src/img/logo.png'); | |
/* width:180px; */ | |
/* height:46px; */ | |
} | |
/* ... and similar CSS hacks ... */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openerp.web_myaddon = function(openerp) { | |
var hostname = window.location.hostname, | |
params = jQuery.param != undefined && jQuery.deparam(jQuery.param.querystring()) | |
if (!openerp.web_myaddon) { | |
/** @namespace */ | |
openerp.web_myaddon = {}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MagicList(list): | |
def __getitem__(self, key): | |
if not isinstance(key, tuple): | |
return list.__getitem__(self, key) | |
rv = [] | |
for element in key: | |
value = list.__getitem__(self, element) | |
if isinstance(element, slice): | |
rv.extend(value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dateutil.parser | |
from babel.core import Locale | |
class LocalizedParserinfo(dateutil.parser.parserinfo): | |
def __init__(self, locale): | |
locale = Locale.parse(locale) | |
# Build localized list of words, remove dots | |
self.WEEKDAYS = [(locale.days['format']['wide'][i], | |
locale.days['format']['abbreviated'][i].rstrip('.')) |
NewerOlder