Skip to content

Commit

Permalink
[OU-IMP] product: populate product_document table from attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Oct 28, 2024
1 parent 23eeb32 commit 2e3a73d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 12 additions & 0 deletions openupgrade_scripts/scripts/product/17.0.1.2/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,15 @@
def migrate(env, version):
openupgrade.load_data(env, "product", "17.0.1.2/noupdate_changes.xml")
openupgrade.delete_records_safely_by_xml_id(env, ["product.list0"])
openupgrade.logged_query(
env.cr,
"""
INSERT INTO product_document (
ir_attachment_id, active, create_uid, write_uid, create_date, write_date
)
SELECT id, True, create_uid, write_uid, create_date, write_date
FROM ir_attachment
WHERE res_model IN ('product.product', 'product.template')
AND res_field IS NULL
""",
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ product / product.category / product_properties_definition (propert
product / product.document / _inherits : NEW _inherits: {'ir.attachment': 'ir_attachment_id'}
product / product.document / active (boolean) : NEW hasdefault: default
product / product.document / ir_attachment_id (many2one) : NEW relation: ir.attachment, required
# NOTHING TO DO: fields in new model
# DONE: populated in post-migration with attachments on products

product / product.packaging / product_id (many2one) : now required
# NOTHING TO DO
Expand All @@ -37,9 +37,11 @@ product / product.pricelist.item / active (boolean) : DEL
product / product.product / activity_user_id (many2one) : not related anymore
product / product.product / activity_user_id (many2one) : now a function
product / product.product / message_main_attachment_id (many2one): DEL relation: ir.attachment
product / product.product / product_document_ids (one2many): NEW relation: product.document
# NOTHING TO DO

product / product.product / product_document_ids (one2many): NEW relation: product.document
# DONE: populated in post-migration with attachments on products

product / product.supplierinfo / discount (float) : NEW
# NOTHING TO DO

Expand All @@ -49,10 +51,12 @@ product / product.tag / color (integer) : type i
product / product.template / activity_user_id (many2one) : not related anymore
product / product.template / activity_user_id (many2one) : now a function
product / product.template / message_main_attachment_id (many2one): DEL relation: ir.attachment
product / product.template / product_document_ids (one2many): NEW relation: product.document
product / product.template / product_properties (properties): NEW hasdefault: compute
# NOTHING TO DO

product / product.template / product_document_ids (one2many): NEW relation: product.document
# DONE: populated in post-migration with attachments on products

product / product.template.attribute.line / _order : _order is now 'sequence, attribute_id, id' ('attribute_id, id')
product / product.template.attribute.line / sequence (integer) : NEW hasdefault: default
# NOTHING TO DO: new feature
Expand Down

0 comments on commit 2e3a73d

Please sign in to comment.