mirror of https://github.com/muk-it/muk_base
MuK IT GmbH
6 years ago
8 changed files with 296 additions and 109 deletions
-
2muk_utils/__manifest__.py
-
139muk_utils/i18n/de.po
-
100muk_utils/i18n/muk_utils.pot
-
2muk_utils/models/res_groups.py
-
3muk_utils/tools/__init__.py
-
53muk_utils/tools/cache.py
-
57muk_utils/tools/file.py
-
45muk_utils/tools/json.py
@ -1,108 +1,123 @@ |
|||||
# Translation of Odoo Server. |
# Translation of Odoo Server. |
||||
# This file contains the translation of the following modules: |
# This file contains the translation of the following modules: |
||||
# * muk_utils |
|
||||
|
# * muk_utils |
||||
# |
# |
||||
msgid "" |
msgid "" |
||||
msgstr "" |
msgstr "" |
||||
"Project-Id-Version: Odoo Server 11.0\n" |
|
||||
|
"Project-Id-Version: Odoo Server 11.0-20181126\n" |
||||
"Report-Msgid-Bugs-To: \n" |
"Report-Msgid-Bugs-To: \n" |
||||
"POT-Creation-Date: 2018-06-07 14:50+0000\n" |
|
||||
"PO-Revision-Date: 2018-06-07 14:50+0000\n" |
|
||||
|
"POT-Creation-Date: 2018-12-10 12:59+0000\n" |
||||
|
"PO-Revision-Date: 2018-12-10 14:12+0100\n" |
||||
"Last-Translator: <>\n" |
"Last-Translator: <>\n" |
||||
"Language-Team: \n" |
"Language-Team: \n" |
||||
"MIME-Version: 1.0\n" |
"MIME-Version: 1.0\n" |
||||
"Content-Type: text/plain; charset=UTF-8\n" |
"Content-Type: text/plain; charset=UTF-8\n" |
||||
"Content-Transfer-Encoding: \n" |
|
||||
|
"Content-Transfer-Encoding: 8bit\n" |
||||
"Plural-Forms: \n" |
"Plural-Forms: \n" |
||||
|
"Language: de\n" |
||||
|
"X-Generator: Poedit 2.1.1\n" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_lock_create_uid |
|
||||
msgid "Created by" |
|
||||
msgstr "Erstellt von" |
|
||||
|
#: model:ir.model,name:muk_utils.model_res_groups |
||||
|
msgid "Access Groups" |
||||
|
msgstr "Berechtigungsgruppen" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_lock_create_date |
|
||||
msgid "Created on" |
|
||||
msgstr "Erstellt am" |
|
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups_child_groups |
||||
|
msgid "Child Groups" |
||||
|
msgstr "Geerbte Gruppen" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_base_display_name |
|
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_lock_display_name |
|
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_locking_display_name |
|
||||
msgid "Display Name" |
|
||||
msgstr "Anzeigename" |
|
||||
|
#: model:ir.actions.server,name:muk_utils.cron_utils_update_groups_ir_actions_server |
||||
|
#: model:ir.cron,cron_name:muk_utils.cron_utils_update_groups |
||||
|
#: model:ir.cron,name:muk_utils.cron_utils_update_groups |
||||
|
msgid "Cron job to update the Groups" |
||||
|
msgstr "Cron-Job zum aktualisieren der Gruppen" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_base_id |
|
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_lock_id |
|
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_locking_id |
|
||||
msgid "ID" |
|
||||
msgstr "ID" |
|
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups_departments |
||||
|
msgid "Departments" |
||||
|
msgstr "Abteilungen" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_base___last_update |
|
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_lock___last_update |
|
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_locking___last_update |
|
||||
msgid "Last Modified on" |
|
||||
msgstr "Zuletzt geändert am" |
|
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups_display_name |
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_model_display_name |
||||
|
msgid "Display Name" |
||||
|
msgstr "Anzeigename" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_lock_write_uid |
|
||||
msgid "Last Updated by" |
|
||||
msgstr "Zuletzt aktualisiert durch" |
|
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups_explicit_users |
||||
|
msgid "Explicit Users" |
||||
|
msgstr "Zusätzliche Benutzer" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_lock_write_date |
|
||||
msgid "Last Updated on" |
|
||||
msgstr "Zuletzt aktualisiert am" |
|
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_quality_docs_groups_name |
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_security_groups_name |
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups_name |
||||
|
msgid "Group Name" |
||||
|
msgstr "Gruppenname" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model,name:muk_utils.model_muk_utils_lock |
|
||||
msgid "Lock" |
|
||||
msgstr "Lock" |
|
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups_groups |
||||
|
msgid "Groups" |
||||
|
msgstr "Gruppen" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_lock_locked_by |
|
||||
msgid "Locked by" |
|
||||
msgstr "Locked by" |
|
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups_id |
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_model_id |
||||
|
msgid "ID" |
||||
|
msgstr "ID" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model,name:muk_utils.model_muk_utils_base |
|
||||
msgid "MuK Base Model" |
|
||||
msgstr "MuK Base Model" |
|
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups_jobs |
||||
|
msgid "Jobs" |
||||
|
msgstr "Stellen" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model,name:muk_utils.model_muk_utils_locking |
|
||||
msgid "MuK Locking Model" |
|
||||
msgstr "MuK Locking Model" |
|
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups___last_update |
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_model___last_update |
||||
|
msgid "Last Modified on" |
||||
|
msgstr "Zuletzt geändert am" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_lock_name |
|
||||
msgid "Name" |
|
||||
msgstr "Name" |
|
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_quality_docs_groups_parent_left |
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_security_groups_parent_left |
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups_parent_left |
||||
|
msgid "Left Parent" |
||||
|
msgstr "Left Parent" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_lock_lock_ref |
|
||||
msgid "Object Reference" |
|
||||
msgstr "Object Reference" |
|
||||
|
#: model:ir.model,name:muk_utils.model_muk_utils_model |
||||
|
msgid "MuK Base Model" |
||||
|
msgstr "MuK Base Model" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_lock_operation |
|
||||
msgid "Operation" |
|
||||
msgstr "Operation" |
|
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups_parent_group |
||||
|
msgid "Parent Group" |
||||
|
msgstr "Übergeordnete Gruppe" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_lock_token |
|
||||
msgid "Token" |
|
||||
msgstr "Token" |
|
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_quality_docs_groups_parent_right |
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_security_groups_parent_right |
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups_parent_right |
||||
|
msgid "Right Parent" |
||||
|
msgstr "Right Parent" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: selection:muk_utils.lock,locked_by_ref:0 |
|
||||
msgid "User" |
|
||||
msgstr "User" |
|
||||
|
#: sql_constraint:muk_utils.groups:0 |
||||
|
msgid "The name of the group must be unique!" |
||||
|
msgstr "Der Gruppenname muss eindeutig sein!" |
||||
|
|
||||
#. module: muk_utils |
#. module: muk_utils |
||||
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_lock_locked_by_ref |
|
||||
msgid "User Reference" |
|
||||
msgstr "User Reference" |
|
||||
|
#: model:ir.model,name:muk_utils.model_res_users |
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_quality_docs_groups_count_users |
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_security_groups_count_users |
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups_count_users |
||||
|
#: model:ir.model.fields,field_description:muk_utils.field_muk_utils_groups_users |
||||
|
msgid "Users" |
||||
|
msgstr "Benutzer" |
||||
|
|
||||
|
#. module: muk_utils |
||||
|
#: model:ir.model,name:muk_utils.model_muk_utils_groups |
||||
|
msgid "muk_utils.groups" |
||||
|
msgstr "muk_utils.groups" |
@ -0,0 +1,53 @@ |
|||||
|
################################################################################### |
||||
|
# |
||||
|
# Copyright (C) 2018 MuK IT GmbH |
||||
|
# |
||||
|
# This program is free software: you can redistribute it and/or modify |
||||
|
# it under the terms of the GNU Affero General Public License as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU Affero General Public License for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU Affero General Public License |
||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################### |
||||
|
|
||||
|
import time |
||||
|
|
||||
|
class memoize(object): |
||||
|
_caches = {} |
||||
|
_timeouts = {} |
||||
|
|
||||
|
def __init__(self, timeout=2): |
||||
|
self.timeout = timeout |
||||
|
|
||||
|
def collect(self): |
||||
|
for func in self._caches: |
||||
|
cleaned_cache = {} |
||||
|
current_time = time.time() |
||||
|
for key in self._caches[func]: |
||||
|
if (current_time - self._caches[func][key][1]) < self._timeouts[func]: |
||||
|
cleaned_cache[key] = self._caches[func][key] |
||||
|
self._caches[func] = cleaned_cache |
||||
|
|
||||
|
def __call__(self, func): |
||||
|
self.cache = self._caches[func] = {} |
||||
|
self._timeouts[func] = self.timeout |
||||
|
def wrapper(*args, **kwargs): |
||||
|
current_time = time.time() |
||||
|
kw = sorted(kwargs.items()) |
||||
|
key = (args, tuple(kw)) |
||||
|
try: |
||||
|
value = self.cache[key] |
||||
|
if (current_time - value[1]) > self.timeout: |
||||
|
raise KeyError |
||||
|
except KeyError: |
||||
|
value = self.cache[key] = (func(*args,**kwargs), current_time) |
||||
|
return value[0] |
||||
|
wrapper.func_name = func.__name__ |
||||
|
return wrapper |
@ -0,0 +1,57 @@ |
|||||
|
################################################################################### |
||||
|
# |
||||
|
# Copyright (C) 2018 MuK IT GmbH |
||||
|
# |
||||
|
# This program is free software: you can redistribute it and/or modify |
||||
|
# it under the terms of the GNU Affero General Public License as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU Affero General Public License for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU Affero General Public License |
||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################### |
||||
|
|
||||
|
import os |
||||
|
import io |
||||
|
import base64 |
||||
|
import shutil |
||||
|
import urllib |
||||
|
import logging |
||||
|
import tempfile |
||||
|
import mimetypes |
||||
|
|
||||
|
from odoo.tools.mimetypes import guess_mimetype |
||||
|
|
||||
|
_logger = logging.getLogger(__name__) |
||||
|
|
||||
|
def unique_name(name, names, escape_suffix=False): |
||||
|
def compute_name(name, suffix, escape_suffix): |
||||
|
if escape_suffix: |
||||
|
name, extension = os.path.splitext(name) |
||||
|
return "%s(%s)%s" % (name, suffix, extension) |
||||
|
else: |
||||
|
return "%s(%s)" % (name, suffix) |
||||
|
if not name in names: |
||||
|
return name |
||||
|
else: |
||||
|
suffix = 1 |
||||
|
name = compute_name(name, suffix, escape_suffix) |
||||
|
while name in names: |
||||
|
suffix += 1 |
||||
|
name = compute_name(name, suffix, escape_suffix) |
||||
|
return name |
||||
|
|
||||
|
def guess_extension(filename=None, mimetype=None, binary=None): |
||||
|
extension = filename and os.path.splitext(filename)[1][1:].strip().lower() |
||||
|
if not extension and mimetype: |
||||
|
extension = mimetypes.guess_extension(mimetype)[1:].strip().lower() |
||||
|
if not extension and binary: |
||||
|
mimetype = guess_mimetype(binary, default="") |
||||
|
extension = mimetypes.guess_extension(mimetype)[1:].strip().lower() |
||||
|
return extension |
@ -0,0 +1,45 @@ |
|||||
|
################################################################################### |
||||
|
# |
||||
|
# Copyright (C) 2018 MuK IT GmbH |
||||
|
# |
||||
|
# This program is free software: you can redistribute it and/or modify |
||||
|
# it under the terms of the GNU Affero General Public License as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU Affero General Public License for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU Affero General Public License |
||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################### |
||||
|
|
||||
|
import json |
||||
|
import logging |
||||
|
import datetime |
||||
|
|
||||
|
from odoo import models, tools |
||||
|
|
||||
|
_logger = logging.getLogger(__name__) |
||||
|
|
||||
|
class ResponseEncoder(json.JSONEncoder): |
||||
|
|
||||
|
def default(self, obj): |
||||
|
if isinstance(obj, datetime.date): |
||||
|
return obj.strftime(tools.DEFAULT_SERVER_DATE_FORMAT) |
||||
|
if isinstance(obj, datetime.datetime): |
||||
|
return obj.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT) |
||||
|
if isinstance(obj, (bytes, bytearray)): |
||||
|
return obj.decode() |
||||
|
return json.JSONEncoder.default(self, obj) |
||||
|
|
||||
|
class RecordEncoder(ResponseEncoder): |
||||
|
|
||||
|
def default(self, obj): |
||||
|
if isinstance(obj, models.BaseModel): |
||||
|
return obj.name_get() |
||||
|
return ResponseEncoder.default(self, obj) |
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue