Browse Source

publish muk_attachment_lobject - 12.0

pull/9/head
MuK IT GmbH 5 years ago
parent
commit
ff2291e388
  1. 5
      muk_attachment_lobject/__manifest__.py
  2. 6
      muk_attachment_lobject/models/ir_attachment.py
  3. 18
      muk_attachment_lobject/tests/test_attachment.py
  4. 36
      muk_attachment_lobject/views/ir_attachment.xml

5
muk_attachment_lobject/__manifest__.py

@ -20,7 +20,7 @@
{
"name": "MuK Large Objects Attachment",
"summary": """Large Objects Attachment Location""",
"version": '12.0.2.1.4',
"version": '12.0.2.1.7',
"category": 'Extra Tools',
"license": "AGPL-3",
"website": "http://www.mukit.at",
@ -32,6 +32,9 @@
'depends': [
'muk_fields_lobject',
],
"data": [
"views/ir_attachment.xml",
],
"qweb": [
"static/src/xml/*.xml",
],

6
muk_attachment_lobject/models/ir_attachment.py

@ -70,6 +70,7 @@ class LObjectIrAttachment(models.Model):
'lobject': ('store_lobject', '=', False),
}
record_domain = [
'&', ('type', '=', 'binary'),
'&', storage_domain[self._storage()],
'|', ('res_field', '=', False), ('res_field', '!=', False)
]
@ -106,9 +107,8 @@ class LObjectIrAttachment(models.Model):
vals = self._get_datas_inital_vals()
vals = self._update_datas_vals(vals, attach, bin_data)
vals['store_lobject'] = bin_data
fname = attach.store_fname
clean_vals = self._get_datas_clean_vals(attach)
super(LObjectIrAttachment, attach.sudo()).write(vals)
if fname:
self._file_delete(fname)
self._clean_datas_after_write(clean_vals)
else:
super(LObjectIrAttachment, attach)._inverse_datas()

18
muk_attachment_lobject/tests/test_attachment.py

@ -27,17 +27,19 @@ _logger = logging.getLogger(__name__)
class AttachmentTestCase(common.HttpCase):
at_install = False
post_install = True
def setUp(self):
super(AttachmentTestCase, self).setUp()
super(MigrationTestCase, self).setUp()
self.attachment = self.env['ir.attachment'].sudo()
self.param = self.env['ir.config_parameter'].sudo()
self.param.set_param('ir_attachment.location', 'lobject')
self.params = self.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):
super(AttachmentTestCase, self).tearDown()
self.params.set_param('ir_attachment.location', self.location)
super(MigrationTestCase, self).tearDown()
def test_attachment(self):
attach = self.attachment.create({

36
muk_attachment_lobject/views/ir_attachment.xml

@ -0,0 +1,36 @@
<?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_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='storage']" position="inside">
<group string="Storage" name="storage" groups="base.group_no_one">
<field name="store_lobject" readonly="1" attrs="{'invisible':[('store_lobject','=',False)]}"/>
</group>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save