Skip to content

Commit

Permalink
Merge pull request #2844 from ForgeFlow/14.0-mig-purchase
Browse files Browse the repository at this point in the history
[14.0][OU-ADD] purchase: Migration scripts
  • Loading branch information
pedrobaeza authored Mar 27, 2022
2 parents 499314e + 7d0b0cc commit 545c61a
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docsource/modules130-140.rst
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ Module coverage 13.0 -> 14.0
+--------------------------------------------+-------------------------------------------------+
|project_timesheet_holidays | |
+--------------------------------------------+-------------------------------------------------+
|purchase | |
|purchase | Done |
+--------------------------------------------+-------------------------------------------------+
|purchase_mrp | |
+--------------------------------------------+-------------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<record id="portal_purchase_order_line_rule" model="ir.rule">
<field name="name">Portal Purchase Order Lines</field>
</record>
<record id="purchase_bill_union_comp_rule" model="ir.rule">
<!-- <record id="purchase_bill_union_comp_rule" model="ir.rule">
<field name="global"/>
</record>
<record id="purchase_order_comp_rule" model="ir.rule">
Expand All @@ -42,7 +42,7 @@
</record>
<record id="purchase_order_report_comp_rule" model="ir.rule">
<field name="global"/>
</record>
</record> -->
<record id="purchase_user_account_move_line_rule" model="ir.rule">
<field name="domain_force">[('move_id.move_type', 'in', ('in_invoice', 'in_refund', 'in_receipt'))]</field>
</record>
Expand Down
15 changes: 15 additions & 0 deletions openupgrade_scripts/scripts/purchase/14.0.1.2/post-migration.py
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 openupgrade_scripts/scripts/purchase/14.0.1.2/pre-migration.py
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)
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

0 comments on commit 545c61a

Please sign in to comment.