Skip to content

Commit ccee11e

Browse files
[MIG] stock_account
1 parent 844bb88 commit ccee11e

File tree

4 files changed

+139
-1
lines changed

4 files changed

+139
-1
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---Models in module 'stock_account'---
2+
new model stock.valuation.layer
3+
# DONE: post-migration: try to use data from product.price.history in some way (?)
4+
5+
---Fields in module 'stock_account'---
6+
stock_account / account.move.line / is_anglo_saxon_line (boolean) : NEW
7+
# TODO (?): is there a way to know which lines are anglosaxon??
8+
9+
stock_account / product.product / valuation (char) : selection_keys is now 'function' ('False')
10+
stock_account / product.product / valuation (char) : type is now 'selection' ('char')
11+
stock_account / product.product / cost_method (char) : selection_keys is now 'function' ('False')
12+
stock_account / product.product / cost_method (char) : type is now 'selection' ('char')
13+
stock_account / product.template / cost_method (char) : not a function anymore
14+
stock_account / product.template / cost_method (char) : now related
15+
stock_account / product.template / cost_method (char) : selection_keys is now 'function' ('False')
16+
stock_account / product.template / cost_method (char) : type is now 'selection' ('char')
17+
stock_account / product.template / valuation (char) : not a function anymore
18+
stock_account / product.template / valuation (char) : now related
19+
stock_account / product.template / valuation (char) : selection_keys is now 'function' ('False')
20+
stock_account / product.template / valuation (char) : type is now 'selection' ('char')
21+
# NOTHING TO DO: they are non stored fields
22+
23+
stock_account / product.template / property_cost_method (selection): DEL selection_keys: ['average', 'fifo', 'standard']
24+
stock_account / product.template / property_stock_account_input (many2one): DEL relation: account.account
25+
stock_account / product.template / property_stock_account_output (many2one): DEL relation: account.account
26+
stock_account / product.template / property_valuation (selection): DEL selection_keys: ['manual_periodic', 'real_time']
27+
# NOTHING TO DO: they use now the same fields from product.category instead
28+
29+
stock_account / stock.move / remaining_qty (float) : DEL
30+
stock_account / stock.move / remaining_value (float) : DEL
31+
stock_account / stock.move / value (float) : DEL
32+
stock_account / stock.valuation.layer / remaining_qty (float) : NEW
33+
stock_account / stock.valuation.layer / remaining_value (float) : NEW
34+
stock_account / stock.valuation.layer / value (float) : NEW
35+
# NOTHING TO DO: the relation between moves and valuation layers is new
36+
# TODO (?): if the link with the stock move is found, then fill values
37+
38+
stock_account / stock.valuation.layer / account_move_id (many2one) : NEW relation: account.move
39+
stock_account / stock.valuation.layer / company_id (many2one) : NEW relation: res.company, required
40+
stock_account / stock.valuation.layer / description (char) : NEW
41+
stock_account / stock.valuation.layer / product_id (many2one) : NEW relation: product.product, required
42+
stock_account / stock.valuation.layer / quantity (float) : NEW
43+
stock_account / stock.valuation.layer / stock_move_id (many2one) : NEW relation: stock.move
44+
stock_account / stock.valuation.layer / unit_cost (float) : NEW
45+
stock_account / stock.valuation.layer / stock_valuation_layer_id (many2one): NEW relation: stock.valuation.layer
46+
stock_account / account.move / stock_valuation_layer_ids (one2many): NEW relation: stock.valuation.layer
47+
stock_account / product.product / stock_valuation_layer_ids (one2many): NEW relation: stock.valuation.layer
48+
stock_account / stock.move / stock_valuation_layer_ids (one2many): NEW relation: stock.valuation.layer
49+
stock_account / stock.valuation.layer / stock_valuation_layer_ids (one2many): NEW relation: stock.valuation.layer
50+
# DONE: post-migration: handle the new model (try to use data from product.price.history in some way?)
51+
52+
---XML records in module 'stock_account'---
53+
NEW ir.actions.act_window: stock_account.stock_valuation_layer_action
54+
DEL ir.actions.act_window: stock_account.product_valuation_action
55+
NEW ir.model.access: stock_account.access_stock_valuation_layer
56+
NEW ir.rule: stock_account.stock_valuation_layer_company_rule
57+
NEW ir.ui.view: stock_account.product_template_tree_view
58+
NEW ir.ui.view: stock_account.stock_valuation_layer_form
59+
NEW ir.ui.view: stock_account.stock_valuation_layer_picking
60+
NEW ir.ui.view: stock_account.stock_valuation_layer_search
61+
NEW ir.ui.view: stock_account.stock_valuation_layer_tree
62+
NEW ir.ui.view: stock_account.view_inventory_tree
63+
NEW ir.ui.view: stock_account.view_stock_quant_tree_editable_inherit
64+
NEW ir.ui.view: stock_account.view_stock_quant_tree_inherit
65+
DEL ir.ui.view: stock_account.view_move_tree_valuation_at_date
66+
DEL ir.ui.view: stock_account.view_stock_account_aml
67+
DEL ir.ui.view: stock_account.view_stock_product_tree2
68+
DEL ir.ui.view: stock_account.view_stock_quantity_history
69+
# NOTHING TO DO
70+
71+
NEW ir.ui.view: stock_account.product_product_normal_form_view_inherit
72+
DEL ir.ui.view: stock_account.product_normal_form_view_inherit
73+
# DONE: pre-migration: xmlid renamed (to avoid a xpath issue)
74+
75+
DEL ir.property: stock_account.default_cost_method (noupdate)
76+
DEL ir.property: stock_account.default_valuation (noupdate)
77+
DEL ir.property: stock_account.property_stock_account_input_prd (noupdate)
78+
DEL ir.property: stock_account.property_stock_account_output_prd (noupdate)
79+
# DONE: post-migration: try to delete
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright 2020 ForgeFlow <http://www.forgeflow.com>
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
from openupgradelib import openupgrade
4+
5+
6+
def fill_stock_valuation_layer(env):
7+
openupgrade.logged_query(
8+
env.cr, """
9+
ALTER TABLE stock_valuation_layer
10+
ADD COLUMN old_product_price_history_id integer""",
11+
)
12+
product_ids = env['product.product'].search(
13+
[('type', '=', 'product')]).ids
14+
if product_ids:
15+
openupgrade.logged_query(
16+
env.cr, """
17+
INSERT INTO stock_valuation_layer (old_product_price_history_id,
18+
company_id, product_id, quantity, unit_cost, description,
19+
create_uid, create_date, write_uid, write_date)
20+
SELECT pph.id, pph.company_id, pph.product_id, 0, pph2.cost,
21+
pt.name, pph2.create_uid, pph2.create_date, pph2.write_uid,
22+
pph2.write_date
23+
FROM (SELECT max(id) as id, company_id, product_id
24+
FROM product_price_history
25+
GROUP BY company_id, product_id
26+
ORDER BY id
27+
) pph
28+
JOIN product_price_history pph2 ON pph.id = pph2.id
29+
JOIN product_product pp ON pph.product_id = pp.id
30+
JOIN product_template pt ON pp.product_tmpl_id = pt.id
31+
WHERE pp.id IN %s""", (tuple(product_ids), ),
32+
)
33+
# NOTE: It seems to be incomplete (without the link of the stock move)
34+
35+
36+
@openupgrade.migrate()
37+
def migrate(env, version):
38+
fill_stock_valuation_layer(env)
39+
openupgrade.delete_records_safely_by_xml_id(
40+
env, [
41+
"stock_account.default_cost_method",
42+
"stock_account.default_valuation",
43+
"stock_account.property_stock_account_input_prd",
44+
"stock_account.property_stock_account_output_prd",
45+
]
46+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2020 ForgeFlow <http://www.forgeflow.com>
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
from openupgradelib import openupgrade
4+
5+
_xmlid_renames = [
6+
('stock_account.product_normal_form_view_inherit',
7+
'stock_account.product_product_normal_form_view_inherit'),
8+
]
9+
10+
11+
@openupgrade.migrate()
12+
def migrate(env, version):
13+
openupgrade.rename_xmlids(env.cr, _xmlid_renames)

odoo/openupgrade/doc/source/modules120-130.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ missing in the new release are marked with |del|.
597597
+----------------------------------------------+-------------------------------------------------+
598598
|stock | Done |
599599
+----------------------------------------------+-------------------------------------------------+
600-
|stock_account | |
600+
|stock_account | Done |
601601
+----------------------------------------------+-------------------------------------------------+
602602
|stock_dropshipping | |
603603
+----------------------------------------------+-------------------------------------------------+

0 commit comments

Comments
 (0)