-
-
Notifications
You must be signed in to change notification settings - Fork 402
/
__init__.py
26 lines (21 loc) · 889 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
##############################################################################
# For copyright and license notices, see __manifest__.py file in root directory
##############################################################################
from . import models
from odoo import api, SUPERUSER_ID
def create_code_equal_to_id(cr):
cr.execute("ALTER TABLE crm_lead ADD COLUMN code character varying;")
cr.execute("UPDATE crm_lead SET code = id;")
def assign_old_sequences(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, dict())
lead_obj = env["crm.lead"]
sequence_obj = env["ir.sequence"]
leads = lead_obj.search([], order="id")
for lead_id in leads.ids:
cr.execute(
"UPDATE crm_lead SET code = %s WHERE id = %s;",
(
sequence_obj.next_by_code("crm.lead"),
lead_id,
),
)