Mathias Markl 6 years ago
commit
8a7a78852f
  1. 5
      .gitignore
  2. 45
      .travis.yml
  3. 15
      README.md
  4. 23
      muk_fields_lobject/__init__.py
  5. 58
      muk_fields_lobject/__manifest__.py
  6. 61
      muk_fields_lobject/fields.py
  7. 47
      muk_fields_lobject/models.py
  8. BIN
      muk_fields_lobject/static/description/banner.png
  9. BIN
      muk_fields_lobject/static/description/icon.png

5
.gitignore

@ -0,0 +1,5 @@
.project
.pydevproject
*.pyc
.settings/
.idea

45
.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

15
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

23
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 <http://www.gnu.org/licenses/>.
#
###################################################################################
from . import fields
from . import models

58
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 <http://www.gnu.org/licenses/>.
#
###################################################################################
{
"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 <mathias.markl@mukit.at>",
],
"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,
}

61
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 <http://www.gnu.org/licenses/>.
#
###################################################################################
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

47
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 <http://www.gnu.org/licenses/>.
#
###################################################################################
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

BIN
muk_fields_lobject/static/description/banner.png

After

Width: 880  |  Height: 440  |  Size: 47 KiB

BIN
muk_fields_lobject/static/description/icon.png

After

Width: 250  |  Height: 250  |  Size: 13 KiB

Loading…
Cancel
Save