mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-19 00:32:05 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
32
odoo-bringout-oca-crm-crm_claim_code/crm_claim_code/hooks.py
Normal file
32
odoo-bringout-oca-crm-crm_claim_code/crm_claim_code/hooks.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
|
||||
|
||||
from odoo import SUPERUSER_ID
|
||||
from odoo.api import Environment
|
||||
|
||||
new_field_code_added = False
|
||||
|
||||
|
||||
def create_code_equal_to_id(cr):
|
||||
cr.execute(
|
||||
"SELECT column_name FROM information_schema.columns "
|
||||
"WHERE table_name = 'crm_claim' AND column_name = 'code'"
|
||||
)
|
||||
if not cr.fetchone():
|
||||
cr.execute("ALTER TABLE crm_claim ADD COLUMN code character varying;")
|
||||
cr.execute("UPDATE crm_claim SET code = id;")
|
||||
global new_field_code_added
|
||||
new_field_code_added = True
|
||||
|
||||
|
||||
def assign_old_sequences(cr, registry):
|
||||
if not new_field_code_added:
|
||||
# the field was already existing before the installation of the addon
|
||||
return
|
||||
|
||||
env = Environment(cr, SUPERUSER_ID, {})
|
||||
|
||||
sequence_model = env["ir.sequence"]
|
||||
|
||||
claims = env["crm.claim"].search([], order="id")
|
||||
for claim in claims:
|
||||
claim.code = sequence_model.next_by_code("crm.claim")
|
||||
Loading…
Add table
Add a link
Reference in a new issue