mirror of https://github.com/muk-it/muk_base
MuK IT GmbH
6 years ago
8 changed files with 145 additions and 9 deletions
-
6muk_utils/__manifest__.py
-
5muk_utils/doc/changelog.rst
-
20muk_utils/models/ir_attachment.py
-
2muk_utils/models/res_config_settings.py
-
48muk_utils/tests/test_attachment_migration.py
-
6muk_utils/tests/test_search_parents.py
-
67muk_utils/views/ir_attachment.xml
-
0muk_utils/views/res_config_settings.xml
@ -0,0 +1,48 @@ |
|||||
|
################################################################################### |
||||
|
# |
||||
|
# Copyright (C) 2017 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 base64 |
||||
|
import logging |
||||
|
|
||||
|
from odoo import exceptions |
||||
|
from odoo.tests import common |
||||
|
|
||||
|
_path = os.path.dirname(os.path.dirname(__file__)) |
||||
|
_logger = logging.getLogger(__name__) |
||||
|
|
||||
|
class MigrationTestCase(common.TransactionCase): |
||||
|
|
||||
|
def setUp(self): |
||||
|
super(MigrationTestCase, self).setUp() |
||||
|
self.model = self.env['ir.attachment'] |
||||
|
self.params = env['ir.config_parameter'].sudo() |
||||
|
self.location = self.params.get_param('ir_attachment.location') |
||||
|
if self.location == 'file': |
||||
|
self.params.set_param('ir_attachment.location', 'db') |
||||
|
else: |
||||
|
self.params.set_param('ir_attachment.location', 'file') |
||||
|
|
||||
|
def tearDown(self): |
||||
|
self.params.set_param('ir_attachment.location', self.location) |
||||
|
super(MigrationTestCase, self).tearDown() |
||||
|
|
||||
|
def test_migration(self): |
||||
|
self.model.search([], limit=5).action_migrate() |
||||
|
|
@ -0,0 +1,67 @@ |
|||||
|
<?xml version="1.0" encoding="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/>. |
||||
|
--> |
||||
|
|
||||
|
<odoo> |
||||
|
|
||||
|
<record id="view_attachment_search" model="ir.ui.view"> |
||||
|
<field name="name">ir_attachment.search</field> |
||||
|
<field name="model">ir.attachment</field> |
||||
|
<field name="inherit_id" ref="base.view_attachment_search"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//filter[@name='url_filter']" position="before"> |
||||
|
<separator/> |
||||
|
<filter name="all" string="All Data" domain="['|',('res_field', '=', False),('res_field', '!=', False)]"/> |
||||
|
<filter name="set_res_field" string="Field Data" domain="[('res_field', '!=', False)]"/> |
||||
|
<filter name="no_res_field" string="Attachments" domain="[('res_field', '=', False)]"/> |
||||
|
<separator/> |
||||
|
</xpath> |
||||
|
<xpath expr="//group//filter[last()]" position="before"> |
||||
|
<separator/> |
||||
|
<filter name="group_res_model" string="Attached Document Model" context="{'group_by': 'res_model'}" /> |
||||
|
<filter name="group_res_field" string="Attached Document Field" context="{'group_by': 'res_field'}" /> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="view_attachment_tree" model="ir.ui.view"> |
||||
|
<field name="name">ir_attachment.tree</field> |
||||
|
<field name="model">ir.attachment</field> |
||||
|
<field name="inherit_id" ref="base.view_attachment_tree"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//field[@name='datas_fname']" position="after"> |
||||
|
<field name="mimetype" /> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="view_attachment_form" model="ir.ui.view"> |
||||
|
<field name="name">ir_attachment.form</field> |
||||
|
<field name="model">ir.attachment</field> |
||||
|
<field name="inherit_id" ref="base.view_attachment_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//group[@name='description_group']" position="before"> |
||||
|
<group string="Storage" name="storage" groups="base.group_no_one"> |
||||
|
<field name="db_datas" readonly="1" attrs="{'invisible':[('db_datas','=',False)]}"/> |
||||
|
<field name="store_fname" readonly="1" attrs="{'invisible':[('store_fname','=',False)]}"/> |
||||
|
</group> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue