commit 8a7a78852f1050f51022e47f64b2f4c76f52b6e4 Author: Mathias Markl Date: Fri Jan 12 17:19:51 2018 +0100 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d8d9b73 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.project +.pydevproject +*.pyc +.settings/ +.idea \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4d85708 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,45 @@ +language: python + +python: + - "3.6" + +notifications: + email: false + +sudo: false +cache: pip + +addons: + postgresql: "9.3" + apt: + packages: + - expect-dev + - python-lxml + +env: + global: + - VERSION="11.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0" + + matrix: + - TESTS="1" ODOO_REPO="odoo/odoo" + +before_install: + - sudo apt-get install -y unoconv + - "export PATH=$PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH" + - "if [ $(phantomjs --version) != '2.1.1' ]; then rm -rf $PWD/travis_phantomjs; mkdir -p $PWD/travis_phantomjs; fi" + - "if [ $(phantomjs --version) != '2.1.1' ]; then wget https://assets.membergetmember.co/software/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2; fi" + - "if [ $(phantomjs --version) != '2.1.1' ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi" + - "phantomjs --version" + +install: + - pip install cachetools + - pip install pdfconv + - git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools + - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} + - travis_install_nightly + +script: + - travis_run_tests + +after_success: + - travis_after_tests_success diff --git a/README.md b/README.md new file mode 100644 index 0000000..6091005 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) +[![Build Status](https://travis-ci.org/muk-it/muk_web.svg?branch=11.0)](https://travis-ci.org/muk-it/muk_web) +[![codecov](https://codecov.io/gh/muk-it/muk_web/branch/11.0/graph/badge.svg)](https://codecov.io/gh/muk-it/muk_web) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/eff47569926c435d98a3187623615bc4)](https://www.codacy.com/app/keshrath/muk_web?utm_source=github.com&utm_medium=referral&utm_content=muk-it/muk_web&utm_campaign=Badge_Grade) + +# MuK Odoo Web Modules + +addon | version | summary +--- | --- | --- +[muk_web_client](muk_web_client/) | 11.0 | Odoo Web Client Extension +[muk_web_client_refresh](muk_web_client_refresh/) | 11.0 | Web Client Refresh +[muk_web_preview](muk_web_preview/) | 11.0 | Preview Dialog +[muk_web_preview_attachment](muk_web_preview_attachment/) | 11.0 | Preview Dialog Attachment +[muk_web_share](muk_web_share/) | 11.0 | Share Dialog + diff --git a/muk_fields_lobject/__init__.py b/muk_fields_lobject/__init__.py new file mode 100644 index 0000000..15d1b3e --- /dev/null +++ b/muk_fields_lobject/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +################################################################################### +# +# 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 . +# +################################################################################### + +from . import fields +from . import models \ No newline at end of file diff --git a/muk_fields_lobject/__manifest__.py b/muk_fields_lobject/__manifest__.py new file mode 100644 index 0000000..fea9be0 --- /dev/null +++ b/muk_fields_lobject/__manifest__.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +################################################################################### +# +# 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 . +# +################################################################################### + +{ + "name": "MuK PGSQL Large Objects", + "summary": """PGSQL Large Objects Support""", + "description": """ + Provides a field to store bytes as PostgreSQL + large objects. + """, + "version": '11.0.1.0.0', + "category": 'Extra Tools', + "license": "AGPL-3", + "website": "http://www.mukit.at", + "author": "MuK IT", + "contributors": [ + "Mathias Markl ", + ], + "depends": [ + "base", + ], + "data": [ + ], + "demo": [ + ], + "qweb": [ + "static/src/xml/*.xml", + ], + "images": [ + 'static/description/banner.png' + ], + "external_dependencies": { + "python": [], + "bin": [], + }, + "auto_install": True, + "application": False, + "installable": True, + +} \ No newline at end of file diff --git a/muk_fields_lobject/fields.py b/muk_fields_lobject/fields.py new file mode 100644 index 0000000..98b551d --- /dev/null +++ b/muk_fields_lobject/fields.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- + +################################################################################### +# +# 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 . +# +################################################################################### + +import re +import hashlib +import logging +import psycopg2 + +from odoo import _ +from odoo import models, api, fields +from odoo.tools import ustr, pycompat, human_size + +_logger = logging.getLogger(__name__) + +class LargeObject(fields.Field): + + type = 'lobject' + column_type = ('oid', 'oid') + _slots = { + 'prefetch': False, + 'context_dependent': True, + } + + def convert_to_column(self, value, record, values=None): + if not value: + return None + lobject = record.env.cr._cnx.lobject(0, 'wb') + if isinstance(value, bytes): + lobject.write(value) + else: + lobject.write(value.read()) + return lobject.oid + + def convert_to_record(self, value, record): + if value: + lobject = record.env.cr._cnx.lobject(value, 'rb') + if record._context.get('bin_size') or record._context.get('bin_size_' + self.name): + return human_size(lobject.seek(0, 2)) + elif record._context.get('oid'): + return lobject.oid + else: + return lobject.read() + return False \ No newline at end of file diff --git a/muk_fields_lobject/models.py b/muk_fields_lobject/models.py new file mode 100644 index 0000000..2370626 --- /dev/null +++ b/muk_fields_lobject/models.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- + +################################################################################### +# +# 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 . +# +################################################################################### + +import re +import hashlib +import logging +import psycopg2 + +from odoo import _ +from odoo import models, api, fields +from odoo.tools import ustr, pycompat, human_size + +_logger = logging.getLogger(__name__) + + +unlink = models.BaseModel.unlink + +def large_object_unlink(self): + oids = [] + for name in self._fields: + field = self._fields[name] + if field.type == 'lobject' and field.store: + for record in self: + oids.append(record.with_context({'oid': True})[name]) + unlink(self) + for oid in oids: + lobject = self.env.cr._cnx.lobject(oid, 'rb').unlink() + +models.BaseModel.unlink = large_object_unlink \ No newline at end of file diff --git a/muk_fields_lobject/static/description/banner.png b/muk_fields_lobject/static/description/banner.png new file mode 100644 index 0000000..6a008b7 Binary files /dev/null and b/muk_fields_lobject/static/description/banner.png differ diff --git a/muk_fields_lobject/static/description/icon.png b/muk_fields_lobject/static/description/icon.png new file mode 100644 index 0000000..d5301c7 Binary files /dev/null and b/muk_fields_lobject/static/description/icon.png differ