Browse Source

publish muk_utils - 12.0

pull/9/head
MuK IT GmbH 5 years ago
parent
commit
3c03c1da4b
  1. 3
      muk_utils/__manifest__.py
  2. 30
      muk_utils/actions/ir_attachment.xml
  3. 9
      muk_utils/doc/changelog.rst
  4. 23
      muk_utils/models/ir_attachment.py

3
muk_utils/__manifest__.py

@ -19,7 +19,7 @@
{
"name": "MuK Utils",
"summary": """Utility Features""",
"version": '12.0.1.4.18',
"version": '12.0.1.5.0',
"category": 'Extra Tools',
"license": "AGPL-3",
"author": "MuK IT",
@ -32,6 +32,7 @@
"base_setup",
],
"data": [
"actions/ir_attachment.xml",
"views/mixins_groups.xml",
"views/res_config_settings_view.xml",
],

30
muk_utils/actions/ir_attachment.xml

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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/>.
-->
<odoo>
<record id="action_attachment_migrate" model="ir.actions.server">
<field name="name">Migrate</field>
<field name="model_id" ref="model_ir_attachment" />
<field name="binding_model_id" ref="muk_utils.model_ir_attachment" />
<field name="state">code</field>
<field name="code">records.action_migrate()</field>
</record>
</odoo>

9
muk_utils/doc/changelog.rst

@ -1,3 +1,8 @@
`1.5.0`
-------
- Storage Migration Action
`1.4.0`
-------
@ -16,9 +21,9 @@
`1.1.0`
-------
- Added storage settings
- Added Storage Settings
`1.0.0`
-------
- Init version
- Init Version

23
muk_utils/models/ir_attachment.py

@ -41,7 +41,24 @@ class IrAttachment(models.Model):
'store_fname': False,
'db_datas': False,
}
@api.model
def _update_datas_vals(self, vals, attach, bin_data):
vals.update({
'file_size': len(bin_data),
'checksum': self._compute_checksum(bin_data),
'index_content': self._index(bin_data, attach.datas_fname, attach.mimetype),
})
return vals
#----------------------------------------------------------
# Actions
#----------------------------------------------------------
@api.multi
def action_migrate(self):
self.migrate()
#----------------------------------------------------------
# Functions
#----------------------------------------------------------
@ -93,11 +110,7 @@ class IrAttachment(models.Model):
value = attach.datas
bin_data = base64.b64decode(value) if value else b''
vals = self._get_datas_inital_vals()
vals.update({
'file_size': len(bin_data),
'checksum': self._compute_checksum(bin_data),
'index_content': self._index(bin_data, attach.datas_fname, attach.mimetype),
})
vals = self._update_datas_vals(vals, attach, bin_data)
if value and location != 'db':
vals['store_fname'] = self._file_write(value, vals['checksum'])
else:

Loading…
Cancel
Save