diff --git a/docsource/modules130-140.rst b/docsource/modules130-140.rst
index 09768cbda9eb..53b3183c8a1f 100644
--- a/docsource/modules130-140.rst
+++ b/docsource/modules130-140.rst
@@ -570,7 +570,7 @@ Module coverage 13.0 -> 14.0
+--------------------------------------------+-------------------------------------------------+
|project_timesheet_holidays | |
+--------------------------------------------+-------------------------------------------------+
-|purchase | |
+|purchase | Done |
+--------------------------------------------+-------------------------------------------------+
|purchase_mrp | |
+--------------------------------------------+-------------------------------------------------+
diff --git a/openupgrade_scripts/scripts/purchase/14.0.1.2/noupdate_changes.xml b/openupgrade_scripts/scripts/purchase/14.0.1.2/noupdate_changes.xml
index 532ae5521bc1..7937adbe773a 100644
--- a/openupgrade_scripts/scripts/purchase/14.0.1.2/noupdate_changes.xml
+++ b/openupgrade_scripts/scripts/purchase/14.0.1.2/noupdate_changes.xml
@@ -31,7 +31,7 @@
Portal Purchase Order Lines
-
+
[('move_id.move_type', 'in', ('in_invoice', 'in_refund', 'in_receipt'))]
diff --git a/openupgrade_scripts/scripts/purchase/14.0.1.2/post-migration.py b/openupgrade_scripts/scripts/purchase/14.0.1.2/post-migration.py
new file mode 100644
index 000000000000..3ff8cd5c91ca
--- /dev/null
+++ b/openupgrade_scripts/scripts/purchase/14.0.1.2/post-migration.py
@@ -0,0 +1,15 @@
+# Copyright 2021 ForgeFlow S.L.
+# 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",
+ ],
+ )
diff --git a/openupgrade_scripts/scripts/purchase/14.0.1.2/pre-migration.py b/openupgrade_scripts/scripts/purchase/14.0.1.2/pre-migration.py
new file mode 100644
index 000000000000..78dc5d16549e
--- /dev/null
+++ b/openupgrade_scripts/scripts/purchase/14.0.1.2/pre-migration.py
@@ -0,0 +1,32 @@
+# Copyright 2021 ForgeFlow S.L.
+# 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)
diff --git a/openupgrade_scripts/scripts/purchase/14.0.1.2/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/purchase/14.0.1.2/upgrade_analysis_work.txt
new file mode 100644
index 000000000000..1b1d606b66f5
--- /dev/null
+++ b/openupgrade_scripts/scripts/purchase/14.0.1.2/upgrade_analysis_work.txt
@@ -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