partner-contact/partner_manual_rank/__init__.py
2021-08-01 02:13:14 +00:00

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
"""
)