Skip to content

Commit

Permalink
Merge pull request #1727 from Eficent/12.0-mig-account_voucher
Browse files Browse the repository at this point in the history
[12.0][MIG] account_voucher
  • Loading branch information
pedrobaeza committed Mar 27, 2019
2 parents 8a202a5 + 3df8a46 commit 3d01578
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---Fields in module 'account_voucher'---
account_voucher / account.voucher / company_id (many2one) : is now stored
account_voucher / account.voucher / currency_id (many2one) : is now stored
account_voucher / account.voucher / message_last_post (datetime) : DEL
account_voucher / account.voucher / message_main_attachment_id (many2one): NEW relation: ir.attachment
# NOTHING TO DO

account_voucher / account.voucher / payment_journal_id (many2one) : not a function anymore
account_voucher / account.voucher / payment_journal_id (many2one) : is now stored
# DONE: post-migration: filled if not is in 'draft' state because now this field is stored, so we need to find the correct journal used previously in the payment created

account_voucher / account.voucher.line / analytic_tag_ids (many2many) : NEW relation: account.analytic.tag
# NOTHING TO DO: new feature

---XML records in module 'account_voucher'---
25 changes: 25 additions & 0 deletions addons/account_voucher/migrations/12.0.1.0/post-lol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2019 Eficent <http://www.eficent.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade


def fill_account_voucher_payment_journal_id(cr):
openupgrade.logged_query(
cr, """
UPDATE account_voucher av
SET payment_journal_id = ap.journal_id
FROM account_payment ap
INNER JOIN account_journal aj ON aj.id = ap.journal_id
WHERE av.state != 'draft' AND av.pay_now = 'pay_now'
AND ap.communication = av.name AND av.amount > 0
AND ap.amount = av.amount AND ap.payment_date = av.date
AND ap.currency_id = av.currency_id
AND aj.type IN ('cash', 'bank')
AND av.payment_journal_id IS NULL
"""
)


@openupgrade.migrate()
def migrate(env, version):
fill_account_voucher_payment_journal_id(env.cr)
2 changes: 1 addition & 1 deletion odoo/openupgrade/doc/source/modules110-120.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ missing in the new release are marked with |del|.
+--------------------------------------------+-------------------------------------------------+
|account_test | |
+--------------------------------------------+-------------------------------------------------+
|account_voucher | |
|account_voucher | Done |
+--------------------------------------------+-------------------------------------------------+
|analytic | Done |
+--------------------------------------------+-------------------------------------------------+
Expand Down

0 comments on commit 3d01578

Please sign in to comment.