Skip to content

Commit

Permalink
Merge pull request #4070 from ngochung207-viindoo/16.0-mig-account
Browse files Browse the repository at this point in the history
[16.0][OU-ADD] account: Migration
  • Loading branch information
pedrobaeza authored Oct 24, 2023
2 parents 1193d7f + 0b2ea48 commit dcb7cc3
Show file tree
Hide file tree
Showing 6 changed files with 1,068 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docsource/modules150-160.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Module coverage 15.0 -> 16.0
+-------------------------------------------------+----------------------+-------------------------------------------------+
| Module | Status + Extra Information |
+=================================================+======================+=================================================+
| account | | |
| account |Done | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| account_check_printing | |No DB layout changes. |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<odoo>
<!-- Don't recreate this, as they are usually touched by users and in fact the changes are only to use Command syntax
<record id="account_payment_term_15days" model="account.payment.term">
<field name="line_ids" eval="[Command.clear(), Command.create({'value': 'balance', 'value_amount': 0.0, 'days': 15})]"/>
</record>
Expand All @@ -18,11 +19,12 @@
<record id="account_payment_term_advance_60days" model="account.payment.term">
<field name="line_ids" eval="[ Command.clear(), Command.create({'value': 'percent', 'value_amount': 30.0, 'days': 0}), Command.create({'value': 'balance', 'value_amount': 0.0, 'days': 60})]"/>
</record>
<record id="account_payment_term_end_following_month" model="account.payment.term">
<field name="line_ids" eval="[Command.clear(), Command.create({'value': 'balance', 'value_amount': 0.0, 'months': 1, 'end_month': True})]"/>
</record>
<record id="account_payment_term_immediate" model="account.payment.term">
<field name="line_ids" eval="[Command.clear(), Command.create({'value': 'balance', 'value_amount': 0.0})]"/>
</record> -->
<!-- We distinguish this one, as it requires new fields to be filled -->
<record id="account_payment_term_end_following_month" model="account.payment.term">
<field name="line_ids" eval="[Command.clear(), Command.create({'value': 'balance', 'value_amount': 0.0, 'months': 1, 'end_month': True})]"/>
</record>
<record id="account_send_payment_receipt_by_email_action" model="ir.actions.act_window">
<field name="context" eval="{ 'mail_post_autofollow': True, 'default_composition_mode': 'comment', 'default_use_template': True, 'default_template_id': ref('account.mail_template_data_payment_receipt'), 'default_email_layout_xmlid': 'mail.mail_notification_light', }"/>
Expand Down
53 changes: 53 additions & 0 deletions openupgrade_scripts/scripts/account/16.0.1.2/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2023 Viindoo - Trịnh Ngọc Hưng
# Copyright 2023 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade

_translations_to_delete = [
"email_template_edi_credit_note",
"email_template_edi_invoice",
"mail_template_data_payment_receipt",
]
_deleted_xml_records = [
"account.data_account_off_sheet",
"account.data_account_type_credit_card",
"account.data_account_type_current_assets",
"account.data_account_type_current_liabilities",
"account.data_account_type_depreciation",
"account.data_account_type_direct_costs",
"account.data_account_type_equity",
"account.data_account_type_expenses",
"account.data_account_type_fixed_assets",
"account.data_account_type_liquidity",
"account.data_account_type_non_current_assets",
"account.data_account_type_non_current_liabilities",
"account.data_account_type_other_income",
"account.data_account_type_payable",
"account.data_account_type_prepayments",
"account.data_account_type_receivable",
"account.data_account_type_revenue",
"account.data_unaffected_earnings",
"account.account_tax_carryover_line_comp_rule",
"account.analytic_default_comp_rule",
]


def _compute_remaining_account_payment_amount_company_currency_signed(env):
"""Those payment with different currency than the company ones are not easily
computed by SQL, so we use ORM for these cases, but they should luckily be few.
"""
payments = env["account.payment"].search(
[("amount_company_currency_signed", "=", False)]
)
payments._compute_amount_company_currency_signed()


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env.cr, "account", "16.0.1.2/noupdate_changes.xml")
openupgrade.delete_record_translations(env.cr, "account", _translations_to_delete)
openupgrade.delete_records_safely_by_xml_id(
env,
_deleted_xml_records,
)
_compute_remaining_account_payment_amount_company_currency_signed(env)
Loading

0 comments on commit dcb7cc3

Please sign in to comment.