-
-
Notifications
You must be signed in to change notification settings - Fork 702
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2844 from ForgeFlow/14.0-mig-purchase
[14.0][OU-ADD] purchase: Migration scripts
- Loading branch information
Showing
5 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
openupgrade_scripts/scripts/purchase/14.0.1.2/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.load_data(env.cr, "purchase", "14.0.1.2/noupdate_changes.xml") | ||
openupgrade.delete_record_translations( | ||
env.cr, | ||
"purchase", | ||
[ | ||
"email_template_edi_purchase_done", | ||
], | ||
) |
32 changes: 32 additions & 0 deletions
32
openupgrade_scripts/scripts/purchase/14.0.1.2/pre-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def fill_purchase_order_line_qty_to_invoice(env): | ||
if not openupgrade.column_exists(env.cr, "purchase_order_line", "qty_to_invoice"): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE purchase_order_line | ||
ADD COLUMN qty_to_invoice numeric""", | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE purchase_order_line pol | ||
SET qty_to_invoice = CASE WHEN po.state IN ('purchase', 'done') | ||
AND pt.purchase_method = 'purchase' | ||
THEN pol.product_qty - pol.qty_invoiced | ||
WHEN po.state IN ('purchase', 'done') | ||
THEN pol.qty_received - pol.qty_invoiced | ||
ELSE 0 END | ||
FROM purchase_order po, product_product pp | ||
JOIN product_template pt ON pp.product_tmpl_id = pt.id | ||
WHERE pol.order_id = po.id AND pol.product_id = pp.id""", | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
fill_purchase_order_line_qty_to_invoice(env) |
60 changes: 60 additions & 0 deletions
60
openupgrade_scripts/scripts/purchase/14.0.1.2/upgrade_analysis_work.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
---Models in module 'purchase'--- | ||
---Fields in module 'purchase'--- | ||
purchase / purchase.order / _order : _order is now 'priority desc, id desc' ('date_order desc, id desc') | ||
purchase / purchase.order / date_planned (datetime) : now a function | ||
purchase / purchase.order.line / account_analytic_id (many2one): now a function | ||
purchase / purchase.order.line / analytic_tag_ids (many2many) : now a function | ||
# NOTHING TO DO | ||
|
||
purchase / purchase.order / date_calendar_start (datetime): NEW isfunction: function, stored | ||
# NOTHING TO DO: computed in load | ||
|
||
purchase / purchase.order / mail_reception_confirmed (boolean): NEW hasdefault | ||
purchase / purchase.order / mail_reminder_confirmed (boolean): NEW hasdefault | ||
purchase / purchase.order / priority (selection) : NEW selection_keys: ['0', '1'], hasdefault | ||
# NOTHING TO DO: new features | ||
|
||
purchase / purchase.order.line / qty_to_invoice (float) : NEW isfunction: function, stored | ||
# DONE: pre-migration: fast filled | ||
|
||
purchase / res.partner / receipt_reminder_email (boolean): NEW hasdefault | ||
purchase / res.partner / reminder_date_before_receipt (integer): NEW hasdefault | ||
# NOTHING TO DO: new features | ||
|
||
---XML records in module 'purchase'--- | ||
NEW digest.tip: purchase.digest_tip_purchase_0 | ||
NEW digest.tip: purchase.digest_tip_purchase_1 | ||
NEW ir.actions.act_window: purchase.action_rfq_form | ||
NEW ir.actions.act_window: purchase.purchase_action_dashboard_kanban | ||
NEW ir.actions.act_window: purchase.purchase_action_dashboard_list | ||
DEL ir.actions.act_window: purchase.purchase_order_action_generic | ||
NEW ir.actions.server: purchase.action_purchase_batch_bills | ||
NEW ir.actions.server: purchase.action_purchase_send_reminder | ||
NEW ir.cron: purchase.purchase_send_reminder_mail (noupdate) | ||
DEL ir.filters: purchase.filter_purchase_order_average_delivery_time | ||
DEL ir.filters: purchase.filter_purchase_order_monthly_purchases | ||
DEL ir.filters: purchase.filter_purchase_order_price_per_supplier | ||
NEW ir.model.access: purchase.access_account_move | ||
NEW ir.model.access: purchase.access_account_move_line_manager | ||
NEW ir.model.access: purchase.access_account_tag_purchase_user | ||
NEW ir.model.access: purchase.access_purchase_order_invoicing_payments_readonly | ||
NEW ir.model.access: purchase.access_purchase_order_line_invoicing_payments_readonly | ||
DEL ir.model.access: purchase.access_account_journal_purchase_manager | ||
DEL ir.model.access: purchase.access_account_move_purchase | ||
DEL ir.model.access: purchase.access_account_move_purchase_manager | ||
DEL ir.model.access: purchase.access_product_group_res_partner_purchase_manager | ||
NEW ir.property: purchase.receipt_reminder_email (noupdate) | ||
NEW ir.property: purchase.reminder_date_before_receipt (noupdate) | ||
NEW ir.ui.menu: purchase.menu_product_attribute_action | ||
NEW ir.ui.menu: purchase.menu_unit_of_measure_in_config_purchase | ||
DEL ir.ui.menu: purchase.menu_report_purchase | ||
NEW ir.ui.view: purchase.assets_backend | ||
NEW ir.ui.view: purchase.assets_frontend | ||
NEW ir.ui.view: purchase.mail_notification_confirm (noupdate) | ||
NEW ir.ui.view: purchase.portal_my_purchase_order_update_date | ||
NEW ir.ui.view: purchase.product_supplierinfo_tree_view2 | ||
NEW ir.ui.view: purchase.purchase_order_kpis_tree | ||
NEW ir.ui.view: purchase.track_po_line_qty_received_template | ||
NEW mail.template: purchase.email_template_edi_purchase_reminder (noupdate) | ||
NEW res.groups: purchase.group_send_reminder | ||
# NOTHING TO DO |