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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
19 additions and
13 deletions
-
account_financial_report_webkit/README.rst
-
account_financial_report_webkit/hooks.py
|
|
@ -166,6 +166,7 @@ Contributors |
|
|
|
* Guewen Baconnier |
|
|
|
* David Dufresne <david.dufresne@savoirfairelinux.com> |
|
|
|
* Luc De Meyer <luc.demeyer@noviat.com> |
|
|
|
* Jairo Llopis <jairo.llopis@tecnativa.com> |
|
|
|
|
|
|
|
Maintainer |
|
|
|
---------- |
|
|
|
|
|
@ -1,23 +1,28 @@ |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
# © 2017 Therp BV <http://therp.nl> |
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
|
|
from psycopg2 import ProgrammingError |
|
|
|
|
|
|
|
from .models.account_move_line import AccountMoveLine |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
cr.execute( |
|
|
|
"""update account_move_line |
|
|
|