[IMP] account_banking_mandate: Put binary field as attachment

For not wasting space in DB. Migration scripts included (requires openupgradelib).
This commit is contained in:
Pedro M. Baeza
2019-05-12 22:08:35 +02:00
committed by Reyes4711
parent 98f6d8cd92
commit 42aea59a85
4 changed files with 37 additions and 2 deletions

View File

@@ -7,7 +7,7 @@
{
'name': 'Account Banking Mandate',
'summary': 'Banking mandates',
'version': '12.0.1.0.0',
'version': '12.0.2.0.0',
'license': 'AGPL-3',
'author': "Compassion CH, "
"Tecnativa, "

View File

@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Tecnativa - Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openupgradelib import openupgrade
from openupgradelib import openupgrade_90
@openupgrade.migrate(use_env=True)
def migrate(env, version):
column = openupgrade.get_legacy_name('scan')
if openupgrade.column_exists(env.cr, 'account_banking_mandate', column):
openupgrade_90.convert_binary_field_to_attachment(
env, {'account.banking.mandate': [('scan', None)]},
)

View File

@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade
column_renames = {
'account_banking_mandate': [
('scan', None),
],
}
@openupgrade.migrate()
def migrate(cr, version):
if openupgrade.column_exists(cr, 'account_banking_mandate', 'scan'):
openupgrade.rename_columns(cr, column_renames)

View File

@@ -53,7 +53,10 @@ class AccountBankingMandate(models.Model):
)
signature_date = fields.Date(string='Date of Signature of the Mandate',
track_visibility='onchange')
scan = fields.Binary(string='Scan of the Mandate')
scan = fields.Binary(
string='Scan of the Mandate',
attachment=True,
)
last_debit_date = fields.Date(string='Date of the Last Debit',
readonly=True)
state = fields.Selection([