Skip to content

Commit

Permalink
[MIG] product_medical: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Tran committed Dec 23, 2024
1 parent 4215f74 commit cf0503e
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 76 deletions.
1 change: 1 addition & 0 deletions product_medical/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Contributors
- `Trobz <https://trobz.com>`__:

- Dung Tran <[email protected]>
- Nhan Tran <[email protected]>

Other credits
-------------
Expand Down
7 changes: 6 additions & 1 deletion product_medical/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Product Medical",
"summary": "Base structure to handle medical products",
"version": "14.0.1.0.1",
"version": "18.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/product-attribute",
"license": "AGPL-3",
Expand All @@ -23,4 +23,9 @@
"views/ppe_category.xml",
],
"installable": True,
"external_dependencies": {
"python": [
"openupgradelib",
],
},
}
39 changes: 0 additions & 39 deletions product_medical/migrations/13.0.1.1.0/post-migration.py

This file was deleted.

42 changes: 42 additions & 0 deletions product_medical/migrations/18.0.1.0.0/pre-migrate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2024 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade

MODEL_TO_RENAMED_FIELDS = {
"product.template": [
("ppe_category_id", "medical_ppe_category_id"),
("in_vitro_diagnostic", "medical_in_vitro_diagnostic"),
("in_vitro_diagnostic", "medical_in_vitro_diagnostic"),
("conformity_declaration_ids", "medical_conformity_declaration_ids"),
("doc_lot_related", "medical_doc_lot_related"),
("doc_validity_date", "medical_doc_validity_date"),
(
"ce_certificate_medical_class_ids",
"medical_ce_certificate_class_ids",
),
("ce_certificate_validity_date", "medical_ce_certificate_validity_date"),
("notified_body_id", "medical_notified_body_id"),
]
}


def _rename_fields(env):
openupgrade.rename_fields(
env,
[
(
model_name,
env[model_name]._table,
field_spec[0],
field_spec[1],
)
for model_name, field_specs in MODEL_TO_RENAMED_FIELDS.items()
for field_spec in field_specs
],
)


@openupgrade.migrate()
def migrate(env, version):
_rename_fields(env)
2 changes: 1 addition & 1 deletion product_medical/models/in_vitro_diagnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class InVitroDiagnostics(models.Model):
_name = "in.vitro.diagnostic"
_description = "In vitro diagnostics"

name = fields.Char(string="Name", required=True, translate=True)
name = fields.Char(required=True, translate=True)

_sql_constraints = [
(
Expand Down
2 changes: 1 addition & 1 deletion product_medical/models/medical_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class MedicineCategory(models.Model):
_name = "medicine.category"
_description = "Medicine Category"

name = fields.Char(string="Name", required=True, translate=True)
name = fields.Char(required=True, translate=True)

_sql_constraints = [
(
Expand Down
2 changes: 1 addition & 1 deletion product_medical/models/medical_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class MedicalClass(models.Model):
_name = "medical.class"
_description = "Medical Class"

name = fields.Char(string="Name", required=True, translate=True)
name = fields.Char(required=True, translate=True)

_sql_constraints = [
(
Expand Down
2 changes: 1 addition & 1 deletion product_medical/models/ppe_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class PPECategory(models.Model):
_name = "ppe.category"
_description = "PPE category"

name = fields.Char(string="Name", required=True)
name = fields.Char(required=True)

_sql_constraints = [
(
Expand Down
24 changes: 13 additions & 11 deletions product_medical/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,36 @@
class ProductTemplate(models.Model):
_inherit = "product.template"

is_medical = fields.Boolean(string="Is Medical", default=False)
is_medical = fields.Boolean(default=False)

medical_certificate_url = fields.Char(string="CE Certificate medical devices")
medical_class_id = fields.Many2one("medical.class", string="Medical Device Class")
medicine_category_id = fields.Many2one("medicine.category", string="Drug Category")
ppe_category_id = fields.Many2one("ppe.category", string="PPE Category")
medical_ppe_category_id = fields.Many2one("ppe.category", string="PPE Category")

in_vitro_diagnostic = fields.Many2one(
medical_in_vitro_diagnostic = fields.Many2one(
"in.vitro.diagnostic", string="In vitro diagnostics"
)
conformity_declaration_ids = fields.Many2many(
medical_conformity_declaration_ids = fields.Many2many(
"ir.attachment",
relation="product_conformity_declaration_rel",
relation="product_medical_conformity_declaration_rel",
column1="product_template_id",
column2="attachment_id",
string="Declaration of Conformity",
)
doc_lot_related = fields.Boolean(string="Lot Related", default=False)
doc_validity_date = fields.Date(string="Validity Date")
ce_certificate_medical_class_ids = fields.Many2many(
medical_doc_lot_related = fields.Boolean(string="Lot Related", default=False)
medical_doc_validity_date = fields.Date(string="Validity Date")
medical_ce_certificate_class_ids = fields.Many2many(
"ir.attachment",
relation="product_ce_certificate_medical_class_rel",
relation="product_medical_ce_certificate_class_rel",
column1="product_template_id",
column2="attachment_id",
string="CE Certificate",
)
ce_certificate_validity_date = fields.Date(string="Certificate Validity Date")
notified_body_id = fields.Many2one(
medical_ce_certificate_validity_date = fields.Date(
string="Certificate Validity Date"
)
medical_notified_body_id = fields.Many2one(
comodel_name="res.partner",
ondelete="set null",
string="Notified Body",
Expand Down
1 change: 1 addition & 0 deletions product_medical/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Iryna Vyshnevska, Camptocamp
- [Trobz](https://trobz.com):
- Dung Tran \<<[email protected]>\>
- Nhan Tran \<<[email protected]>\>
1 change: 1 addition & 0 deletions product_medical/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<li>Iryna Vyshnevska, Camptocamp</li>
<li><a class="reference external" href="https://trobz.com">Trobz</a>:<ul>
<li>Dung Tran &lt;<a class="reference external" href="mailto:dungtd&#64;trobz.com">dungtd&#64;trobz.com</a>&gt;</li>
<li>Nhan Tran &lt;<a class="reference external" href="mailto:nhant&#64;trobz.com">nhant&#64;trobz.com</a>&gt;</li>
</ul>
</li>
</ul>
Expand Down
6 changes: 3 additions & 3 deletions product_medical/views/in_vitro_diagnostic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<field name="name">in.vitro.diagnostic tree</field>
<field name="model">in.vitro.diagnostic</field>
<field name="arch" type="xml">
<tree editable="top">
<list editable="top">
<field name="name" />
</tree>
</list>
</field>
</record>
<record id="in_vitro_diagnostic_action" model="ir.actions.act_window">
<field name="name">In Vitro Diagnostics</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">in.vitro.diagnostic</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create your in vitro diagnostic here.
Expand Down
6 changes: 3 additions & 3 deletions product_medical/views/medical_class.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<field name="name">medical.class tree</field>
<field name="model">medical.class</field>
<field name="arch" type="xml">
<tree editable="top">
<list editable="top">
<field name="name" />
</tree>
</list>
</field>
</record>
<record id="medical_class_action" model="ir.actions.act_window">
<field name="name">Medical Classes</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">medical.class</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create your medical class here.
Expand Down
6 changes: 3 additions & 3 deletions product_medical/views/medicine_category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<field name="name">medicine.category tree</field>
<field name="model">medicine.category</field>
<field name="arch" type="xml">
<tree editable="top">
<list editable="top">
<field name="name" />
</tree>
</list>
</field>
</record>
<record id="medicine_category_action" model="ir.actions.act_window">
<field name="name">Medicine Categories</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">medicine.category</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create your medicine categories here.
Expand Down
6 changes: 3 additions & 3 deletions product_medical/views/ppe_category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<field name="name">ppe.category tree</field>
<field name="model">ppe.category</field>
<field name="arch" type="xml">
<tree editable="top">
<list editable="top">
<field name="name" />
</tree>
</list>
</field>
</record>
<record id="ppe_category_action" model="ir.actions.act_window">
<field name="name">PPE Categories</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">ppe.category</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create your PPE categories here.
Expand Down
18 changes: 9 additions & 9 deletions product_medical/views/product_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
</xpath>
<xpath expr="//form/sheet/notebook" position="inside">
<page name="conformity" string="Conformity">
<group name="conformity">
<group name="medical_conformity">
<group name="conformity_left" string="Categories">
<field name="medical_class_id" />
<field name="medicine_category_id" />
<field name="ppe_category_id" />
<field name="in_vitro_diagnostic" />
<field name="notified_body_id" />
<field name="medical_ppe_category_id" />
<field name="medical_in_vitro_diagnostic" />
<field name="medical_notified_body_id" />
</group>
<group name="conformity_right" string="Documents">
<field
name="conformity_declaration_ids"
name="medical_conformity_declaration_ids"
widget="many2many_binary"
/>
<field name="doc_validity_date" />
<field name="medical_doc_validity_date" />
<field
name="ce_certificate_medical_class_ids"
name="medical_ce_certificate_class_ids"
widget="many2many_binary"
/>
<field name="ce_certificate_validity_date" />
<field name="doc_lot_related" />
<field name="medical_ce_certificate_validity_date" />
<field name="medical_doc_lot_related" />
<field name="medical_certificate_url" widget="url" />
</group>
</group>
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# generated from manifests external_dependencies
openupgradelib

0 comments on commit cf0503e

Please sign in to comment.