Browse Source

Merge pull request #491 from Tecnativa/8.0-account_financial_report_webkit-fix_error_if_column_exists

[FIX] account_financial_report_webkit: Fix error if column exists
pull/635/head
Pedro M. Baeza 6 years ago
committed by GitHub
parent
commit
cfa34d5db7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      account_financial_report_webkit/README.rst
  2. 31
      account_financial_report_webkit/hooks.py

1
account_financial_report_webkit/README.rst

@ -166,6 +166,7 @@ Contributors
* Guewen Baconnier * Guewen Baconnier
* David Dufresne <david.dufresne@savoirfairelinux.com> * David Dufresne <david.dufresne@savoirfairelinux.com>
* Luc De Meyer <luc.demeyer@noviat.com> * Luc De Meyer <luc.demeyer@noviat.com>
* Jairo Llopis <jairo.llopis@tecnativa.com>
Maintainer Maintainer
---------- ----------

31
account_financial_report_webkit/hooks.py

@ -1,23 +1,28 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2017 Therp BV <http://therp.nl> # © 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from psycopg2 import ProgrammingError
from .models.account_move_line import AccountMoveLine from .models.account_move_line import AccountMoveLine
def pre_init_hook(cr): def pre_init_hook(cr):
with cr.savepoint():
# don't break if column exists
cr.execute(
'alter table account_move_line add column last_rec_date date',
)
cr.execute(
'comment on column account_move_line.last_rec_date is %s',
(AccountMoveLine.last_rec_date.string,),
)
cr.execute(
'create index account_move_line_last_rec_date_index '
'on account_move_line (last_rec_date)',
)
# don't break if column exists
try:
with cr.savepoint():
cr.execute(
'alter table account_move_line add column last_rec_date date',
)
cr.execute(
'comment on column account_move_line.last_rec_date is %s',
(AccountMoveLine.last_rec_date.string,),
)
cr.execute(
'create index account_move_line_last_rec_date_index '
'on account_move_line (last_rec_date)',
)
except ProgrammingError:
pass
# but still do the initialization # but still do the initialization
cr.execute( cr.execute(
"""update account_move_line """update account_move_line

Loading…
Cancel
Save