mirror of
https://gitlab.com/flectra-community/partner-contact.git
synced 2024-12-23 12:51:46 +00:00
32 lines
831 B
Python
32 lines
831 B
Python
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||
|
|
||
|
from . import models
|
||
|
from flectra.tools.sql import column_exists
|
||
|
|
||
|
|
||
|
def pre_init_hook(cr):
|
||
|
if not column_exists(cr, "res_partner", "is_customer"):
|
||
|
cr.execute(
|
||
|
"""
|
||
|
ALTER TABLE res_partner
|
||
|
ADD COLUMN is_customer boolean""",
|
||
|
)
|
||
|
cr.execute(
|
||
|
"""
|
||
|
UPDATE res_partner
|
||
|
SET is_customer = customer_rank::boolean
|
||
|
"""
|
||
|
)
|
||
|
if not column_exists(cr, "res_partner", "is_supplier"):
|
||
|
cr.execute(
|
||
|
"""
|
||
|
ALTER TABLE res_partner
|
||
|
ADD COLUMN is_supplier boolean""",
|
||
|
)
|
||
|
cr.execute(
|
||
|
"""
|
||
|
UPDATE res_partner
|
||
|
SET is_supplier = supplier_rank::boolean
|
||
|
"""
|
||
|
)
|