Skip to content

Commit

Permalink
Merge pull request #2843 from ForgeFlow/14.0-mig-sale
Browse files Browse the repository at this point in the history
[14.0][MIG] sale
  • Loading branch information
pedrobaeza authored Jan 2, 2022
2 parents 0b0b4f0 + 17e556d commit abd6f70
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docsource/modules130-140.rst
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ Module coverage 13.0 -> 14.0
+--------------------------------------------+-------------------------------------------------+
|resource | Nothing to do |
+--------------------------------------------+-------------------------------------------------+
|sale | |
|sale | Done |
+--------------------------------------------+-------------------------------------------------+
|sale_coupon | |
+--------------------------------------------+-------------------------------------------------+
Expand Down
24 changes: 19 additions & 5 deletions openupgrade_scripts/scripts/sale/14.0.1.1/noupdate_changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,27 @@
<record id="mt_salesteam_order_sent" model="mail.message.subtype">
<field name="parent_id" ref="sale.mt_order_sent"/>
</record>
<record id="sale_order_comp_rule" model="ir.rule">
<!-- <record id="sale_order_comp_rule" model="ir.rule">
<field name="global"/>
</record>
<record id="sale_order_line_comp_rule" model="ir.rule">
</record> -->
<!-- <record id="sale_order_line_comp_rule" model="ir.rule">
<field name="global"/>
</record>
<record id="sale_order_report_comp_rule" model="ir.rule">
</record> -->
<!-- <record id="sale_order_report_comp_rule" model="ir.rule">
<field name="global"/>
</record> -->
<!-- Added due to the renaming of the XML-IDs -->
<record id="account_invoice_rule_see_all" model="ir.rule">
<field name="domain_force">[('move_type', 'in', ('out_invoice', 'out_refund'))]</field>
</record>
<record id="account_invoice_rule_see_personal" model="ir.rule">
<field name="name">Personal Invoices</field>
<field name="domain_force">[('move_type', 'in', ('out_invoice', 'out_refund')), '|', ('invoice_user_id', '=', user.id), ('invoice_user_id', '=', False)]</field>
</record>
<record id="account_invoice_line_rule_see_all" model="ir.rule">
<field name="domain_force">[('move_id.move_type', 'in', ('out_invoice', 'out_refund'))]</field>
</record>
<record id="account_invoice_line_rule_see_personal" model="ir.rule">
<field name="domain_force">[('move_id.move_type', 'in', ('out_invoice', 'out_refund')), '|', ('move_id.invoice_user_id', '=', user.id), ('move_id.invoice_user_id', '=', False)]</field>
</record>
</odoo>
16 changes: 16 additions & 0 deletions openupgrade_scripts/scripts/sale/14.0.1.1/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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, "sale", "14.0.1.1/noupdate_changes.xml")
openupgrade.delete_record_translations(
env.cr,
"sale",
[
"email_template_edi_sale",
"mail_template_sale_confirmation",
],
)
41 changes: 41 additions & 0 deletions openupgrade_scripts/scripts/sale/14.0.1.1/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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

_xmlid_renames = [
(
"sale.access_product_product_attribute_custom_value",
"sale.access_product_product_attribute_custom_value_sale_manager",
),
("sale.account_move_see_all", "sale.account_invoice_rule_see_all"),
("sale.account_move_personal_rule", "sale.account_invoice_rule_see_personal"),
("sale.account_move_line_see_all", "sale.account_invoice_line_rule_see_all"),
(
"sale.account_move_line_personal_rule",
"sale.account_invoice_line_rule_see_personal",
),
]


def fast_fill_sale_order_currency_id(env):
if not openupgrade.column_exists(env.cr, "sale_order", "currency_id"):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE sale_order
ADD COLUMN currency_id integer""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE sale_order so
SET currency_id = pp.currency_id
FROM product_pricelist pp
WHERE so.pricelist_id = pp.id""",
)


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_xmlids(env.cr, _xmlid_renames)
fast_fill_sale_order_currency_id(env)
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---Models in module 'sale'---
model product.attribute.custom.value (moved to product)
new model sale.order.cancel [transient]
---Fields in module 'sale'---
sale / crm.team / invoiced (integer) : type is now 'float' ('integer')
sale / crm.team / invoiced_target (integer) : type is now 'float' ('integer')
sale / crm.team / quotations_amount (integer) : type is now 'float' ('integer')
# NOTHING TO DO: Automatic conversion from integer to float is assured by PG

sale / product.attribute / display_type (selection) : module is now 'product' ('sale')
sale / product.attribute.custom.value / __last_update (datetime) : module is now 'product' ('sale')
sale / product.attribute.custom.value / _order : module is now 'product' ('sale')
sale / product.attribute.custom.value / custom_product_template_attribute_value_id (many2one): module is now 'product' ('sale')
sale / product.attribute.custom.value / custom_value (char) : module is now 'product' ('sale')
sale / product.attribute.custom.value / display_name (char) : module is now 'product' ('sale')
sale / product.attribute.custom.value / name (char) : module is now 'product' ('sale')
sale / product.attribute.value / display_type (selection) : module is now 'product' ('sale')
sale / product.attribute.value / html_color (char) : module is now 'product' ('sale')
sale / product.attribute.value / is_custom (boolean) : module is now 'product' ('sale')
sale / product.template.attribute.value / display_type (selection) : module is now 'product' ('sale')
sale / product.template.attribute.value / html_color (char) : module is now 'product' ('sale')
sale / product.template.attribute.value / is_custom (boolean) : module is now 'product' ('sale')
sale / sale.order / tag_ids (many2many) : previously in module sale_crm
# NOTHING TO DO: handled by ORM

sale / sale.order / currency_id (many2one) : is now stored
# DONE: pre-migration: fast filled

sale / sale.order / show_update_pricelist (boolean): NEW
# NOTHING TO DO: new technical field

---XML records in module 'sale'---
DEL ir.actions.act_window: sale.action_open_sale_onboarding_sample_quotation
NEW ir.model.access: sale.access_account_invoice_send_salesman
NEW ir.model.access: sale.access_payment_link_wizard_sale
NEW ir.model.access: sale.access_sale_advance_payment_inv
NEW ir.model.access: sale.access_sale_order_cancel
NEW ir.model.access: sale.access_sale_order_line_readonly
NEW ir.model.access: sale.access_sale_order_readonly
NEW ir.model.access: sale.access_sale_payment_acquirer_onboarding_wizard
DEL ir.model.access: sale.access_account_journal_sale_manager
DEL ir.model.access: sale.access_ir_property_sales
# NOTHING TO DO

DEL ir.model.access: sale.access_product_product_attribute_custom_value
NEW ir.model.access: sale.access_product_product_attribute_custom_value_sale_manager
# DONE: pre-migration: renamed xmlid

NEW ir.rule: sale.account_invoice_send_rule_see_all (noupdate)
NEW ir.rule: sale.account_invoice_send_rule_see_personal (noupdate)
NEW ir.rule: sale.sale_advance_payment_inv_rule (noupdate)
NEW ir.rule: sale.sale_order_cancel_rule (noupdate)
NEW ir.rule: sale.sale_payment_acquirer_onboarding_wizard_rule (noupdate)
# NOTHING TO DO

NEW ir.rule: sale.account_invoice_line_rule_see_personal (noupdate)
NEW ir.rule: sale.account_invoice_line_rule_see_all (noupdate)
NEW ir.rule: sale.account_invoice_rule_see_personal (noupdate)
NEW ir.rule: sale.account_invoice_rule_see_all (noupdate)
DEL ir.rule: sale.account_move_line_personal_rule (noupdate)
DEL ir.rule: sale.account_move_line_see_all (noupdate)
DEL ir.rule: sale.account_move_personal_rule (noupdate)
DEL ir.rule: sale.account_move_see_all (noupdate)
# DONE: pre-migration: renamed xmlids

NEW ir.ui.menu: sale.menu_tag_config
NEW ir.ui.view: sale.sale_order_cancel_view_form
NEW ir.ui.view: sale.sale_order_line_view_kanban
DEL ir.ui.view: sale.attribute_tree_view
DEL ir.ui.view: sale.product_attribute_view_form
DEL ir.ui.view: sale.product_template_attribute_line_form
DEL ir.ui.view: sale.product_template_attribute_value_view_form_inherit
DEL ir.ui.view: sale.product_template_attribute_value_view_tree_inherit
DEL ir.ui.view: sale.sale_onboarding_sample_quotation_form
# NOTHING TO DO

0 comments on commit abd6f70

Please sign in to comment.