From ff2291e388ade6cfae848b25465a23e4e861e1dd Mon Sep 17 00:00:00 2001 From: MuK IT GmbH Date: Sat, 16 Feb 2019 19:18:35 +0000 Subject: [PATCH] publish muk_attachment_lobject - 12.0 --- muk_attachment_lobject/__manifest__.py | 5 ++- .../models/ir_attachment.py | 6 ++-- .../tests/test_attachment.py | 18 +++++----- .../views/ir_attachment.xml | 36 +++++++++++++++++++ 4 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 muk_attachment_lobject/views/ir_attachment.xml diff --git a/muk_attachment_lobject/__manifest__.py b/muk_attachment_lobject/__manifest__.py index 8017dff..c45a98b 100644 --- a/muk_attachment_lobject/__manifest__.py +++ b/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", ], diff --git a/muk_attachment_lobject/models/ir_attachment.py b/muk_attachment_lobject/models/ir_attachment.py index 3a50af9..30f44e9 100644 --- a/muk_attachment_lobject/models/ir_attachment.py +++ b/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() \ No newline at end of file diff --git a/muk_attachment_lobject/tests/test_attachment.py b/muk_attachment_lobject/tests/test_attachment.py index 7cf6481..205685b 100644 --- a/muk_attachment_lobject/tests/test_attachment.py +++ b/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({ diff --git a/muk_attachment_lobject/views/ir_attachment.xml b/muk_attachment_lobject/views/ir_attachment.xml new file mode 100644 index 0000000..7b2f9cf --- /dev/null +++ b/muk_attachment_lobject/views/ir_attachment.xml @@ -0,0 +1,36 @@ + + + + + + + + + ir_attachment.form + ir.attachment + + + + + + + + + + + \ No newline at end of file