Skip to content

Commit

Permalink
[MIG] crm_claim_code: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BernatObrador committed Dec 13, 2024
1 parent 4dcb0ab commit fcc1f0b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
4 changes: 4 additions & 0 deletions crm_claim_code/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ Contributors
- Pedro M. Baeza
- Vicent Cubells

- `APSL-Nagarro <https://apsl.tech>`__:

- Bernat Obrador <[email protected]>

Maintainers
-----------

Expand Down
2 changes: 1 addition & 1 deletion crm_claim_code/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
"name": "Sequential Code for Claims",
"version": "16.0.1.0.1",
"version": "17.0.1.0.0",
"category": "Customer Relationship Management",
"author": "AvanzOSC, Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/crm",
Expand Down
16 changes: 6 additions & 10 deletions crm_claim_code/hooks.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
# 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(
def create_code_equal_to_id(env):
env.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;")
if not env.cr.fetchone():
env.cr.execute("ALTER TABLE crm_claim ADD COLUMN code character varying;")
env.cr.execute("UPDATE crm_claim SET code = id;")
global new_field_code_added
new_field_code_added = True


def assign_old_sequences(cr, registry):
def assign_old_sequences(env):
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")
Expand Down
1 change: 0 additions & 1 deletion crm_claim_code/models/crm_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class CrmClaim(models.Model):
string="Claim Number",
required=True,
default="/",
readonly=True,
copy=False,
)

Expand Down
2 changes: 2 additions & 0 deletions crm_claim_code/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
- Ernesto Tejeda
- Pedro M. Baeza
- Vicent Cubells
- [APSL-Nagarro](<https://apsl.tech>):
- Bernat Obrador \<<[email protected]>\>
4 changes: 4 additions & 0 deletions crm_claim_code/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Vicent Cubells</li>
</ul>
</li>
<li><a class="reference external" href="https://apsl.tech">APSL-Nagarro</a>:<ul>
<li>Bernat Obrador &lt;<a class="reference external" href="mailto:bobrador&#64;apsl.net">bobrador&#64;apsl.net</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
4 changes: 2 additions & 2 deletions crm_claim_code/views/crm_claim_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<field name="inherit_id" ref="crm_claim.crm_case_claims_form_view" />
<field name="arch" type="xml">
<field name="name" position="before">
<field name="code" />
<field name="code" readonly="1" />
</field>
</field>
</record>
Expand All @@ -16,7 +16,7 @@
<field name="inherit_id" ref="crm_claim.crm_case_claims_tree_view" />
<field name="arch" type="xml">
<field name="name" position="before">
<field name="code" />
<field name="code" readonly="1" />
</field>
</field>
</record>
Expand Down

0 comments on commit fcc1f0b

Please sign in to comment.