Skip to content

Commit

Permalink
[OU-IMP] stock_account: finish migration
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow committed Feb 10, 2025
1 parent bd948fc commit e8f87ba
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,37 @@ def _stock_move_convert_analytic_account_line_id_m2o_to_m2m(env):
)


def fill_account_move_line_cogs_origin_id(env):
openupgrade.logged_query(
env.cr,
"""
UPDATE account_move_line aml
SET cogs_origin_id = line.id
FROM account_move_line line
WHERE aml.move_id = line.move_id
AND line.display_type != 'cogs' AND aml.display_type = 'cogs'
AND line.product_id = aml.product_id
AND line.product_uom_id = aml.product_uom_id
AND line.quantity = aml.quantity
AND left(line.name, 64) = aml.name""",
)


def delete_obsolete_ir_model_data(env):
xml_ids = [
"stock_account.property_stock_account_input_categ_id",
"stock_account.property_stock_account_output_categ_id",
]
for xml_id in xml_ids:
module, name = xml_id.split(".")
imd = env["ir.model.data"].search(
[("module", "=", module), ("name", "=", name)]
)
imd.unlink()


@openupgrade.migrate()
def migrate(env, version):
_stock_move_convert_analytic_account_line_id_m2o_to_m2m(env)
fill_account_move_line_cogs_origin_id(env)
delete_obsolete_ir_model_data(env)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---Models in module 'stock_account'---
---Fields in module 'stock_account'---
stock_account / account.move.line / cogs_origin_id (many2one) : NEW relation: account.move.line
# NOTHING TO DO: new feature
# DONE: post-migration: filled using display_type = 'cogs'

stock_account / stock.move / analytic_account_line_id (many2one): DEL relation: account.analytic.line
stock_account / stock.move / analytic_account_line_ids (many2many): NEW relation: account.analytic.line
Expand All @@ -17,7 +17,7 @@ NEW ir.filters: stock_account.filter_invoice_inventory_valuation

DEL ir.property: stock_account.property_stock_account_input_categ_id (noupdate)
DEL ir.property: stock_account.property_stock_account_output_categ_id (noupdate)
# NOTHING TO DO: New noupdate="1" records
# DONE: post-migration: ir.model.data deleted to avoid deleting the default values during xmlid cleanup

NEW ir.ui.menu: stock_account.menu_inventory_aging
NEW ir.ui.view: stock_account.stock_valuation_layer_graph
Expand Down

0 comments on commit e8f87ba

Please sign in to comment.