Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0][MIG] puchase_stock #2314

Merged
merged 2 commits into from
May 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/purchase_stock/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
'data/purchase_stock_demo.xml',
],
'installable': True,
'auto_install': False,
'auto_install': True,
'post_init_hook': '_create_buy_rules',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---Models in module 'purchase_stock'---
---Fields in module 'purchase_stock'---
purchase_stock / purchase.order.line / propagate_cancel (boolean) : NEW hasdefault
# DONE: post-migration: set propagate_cancel = False when is not propagated, by default is True

purchase_stock / purchase.order.line / propagate_date (boolean) : NEW
purchase_stock / purchase.order.line / propagate_date_minimum_delta (integer): NEW
# DONE: post-migration: done similar as done in stock module

purchase_stock / purchase.order.line / qty_received_method (False) : NEW selection_keys: ['manual', 'stock_moves'], mode: modify
# DONE: post-migration: filled proper lines with the new method

---XML records in module 'purchase_stock'---
DEL ir.ui.menu: purchase_stock.menu_action_picking_tree_in_move
DEL ir.ui.view: purchase_stock.stock_production_lot_view_form_simple
# NOTHING TO DO
58 changes: 58 additions & 0 deletions addons/purchase_stock/migrations/13.0.1.2/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 2020 ForgeFlow <http://www.forgeflow.com>
# Copyright 2021 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade


def fix_purchase_order_line_propagate_cancel(env):
openupgrade.logged_query(
env.cr, """
UPDATE purchase_order_line pol
SET propagate_cancel = FALSE
FROM stock_move sm
WHERE sm.purchase_line_id = pol.id AND NOT sm.propagate_cancel"""
)


def fill_propagate_date_minimum_delta(env):
# purchase order line
openupgrade.logged_query(
env.cr, """
UPDATE purchase_order_line pol
SET propagate_date_minimum_delta = rc.propagation_minimum_delta
FROM res_company rc
WHERE pol.company_id = rc.id AND
pol.propagate_date_minimum_delta IS NULL
AND rc.propagation_minimum_delta IS NOT NULL
"""
)
openupgrade.logged_query(
env.cr, """
UPDATE purchase_order_line pol
SET propagate_date = TRUE
FROM ir_config_parameter icp
WHERE pol.propagate_date IS NULL
AND icp.key = 'stock.use_propagation_minimum_delta'
AND icp.value = 'True'
"""
)


def fill_purchase_order_line__qty_received_method(env):
"""Set qty_delivered_method = 'stock_moves' on proper lines."""
openupgrade.logged_query(
env.cr, """
UPDATE purchase_order_line pol
SET qty_received_method = 'stock_moves', qty_received_manual = 0
FROM product_product pp
LEFT JOIN product_template pt ON pp.product_tmpl_id = pt.id
WHERE pol.product_id = pp.id AND pol.display_type IS NULL
AND pt.type IN ('consu', 'product')"""
)


@openupgrade.migrate()
def migrate(env, version):
fix_purchase_order_line_propagate_cancel(env)
fill_propagate_date_minimum_delta(env)
fill_purchase_order_line__qty_received_method(env)
2 changes: 1 addition & 1 deletion odoo/openupgrade/doc/source/modules120-130.rst
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ missing in the new release are marked with |del|.
+----------------------------------------------+-------------------------------------------------+
| |new| purchase_requisition_stock | |
+----------------------------------------------+-------------------------------------------------+
|purchase_stock | |
|purchase_stock | Done |
+----------------------------------------------+-------------------------------------------------+
|rating | Nothing to do |
+----------------------------------------------+-------------------------------------------------+
Expand Down