Skip to content

Commit

Permalink
[MIG] account_edi: migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
tranngocson1996 committed Jan 5, 2022
1 parent 0b0b4f0 commit be30008
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docsource/modules130-140.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Module coverage 13.0 -> 14.0
+--------------------------------------------+-------------------------------------------------+
|account_debit_note | |
+--------------------------------------------+-------------------------------------------------+
| |new| account_edi | |
| |new| account_edi | Nothing to do |
+--------------------------------------------+-------------------------------------------------+
| |new| account_edi_extended | |
+--------------------------------------------+-------------------------------------------------+
Expand Down
22 changes: 22 additions & 0 deletions openupgrade_scripts/scripts/account/14.0.1.1/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,27 @@ def add_move_id_field_account_payment(env):
)


def add_edi_state_field_account_move(env):
"""
Module account_edi: Created edi_state column and set the default value is false
"""
if not openupgrade.column_exists(env.cr, "account_move", "edi_state"):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE account_move
ADD COLUMN edi_state varchar
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE account_move
SET edi_state = false
""",
)


def fill_empty_partner_type_account_payment(env):
openupgrade.logged_query(
env.cr,
Expand Down Expand Up @@ -383,6 +404,7 @@ def migrate(env, version):
remove_constrains_reconcile_models(env)
add_move_id_field_account_payment(env)
add_move_id_field_account_bank_statement_line(env)
add_edi_state_field_account_move(env)
fill_empty_partner_type_account_payment(env)
fill_account_move_line_currency_id(env)
fill_account_payment_partner_id(env)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---Models in module 'account_edi'---
new model account.edi.document
new model account.edi.format
# NOTHING TO DO: new models

---Fields in module 'account_edi'---
account_edi / account.edi.document / attachment_id (many2one) : NEW relation: ir.attachment
account_edi / account.edi.document / edi_format_id (many2one) : NEW relation: account.edi.format, required
account_edi / account.edi.document / error (html) : NEW
account_edi / account.edi.document / move_id (many2one) : NEW relation: account.move, required
account_edi / account.edi.document / state (selection) : NEW selection_keys: ['cancelled', 'sent', 'to_cancel', 'to_send']
account_edi / account.edi.format / code (char) : NEW required
account_edi / account.edi.format / name (char) : NEW
account_edi / account.journal / edi_format_ids (many2many) : NEW relation: account.edi.format, isfunction: function, stored
# NOTHING TO DO

account_edi / account.move / edi_document_ids (one2many) : NEW relation: account.edi.document
account_edi / account.move / edi_state (selection) : NEW selection_keys: ['cancelled', 'sent', 'to_cancel', 'to_send'], isfunction: function, stored
# NOTHING TO DO: created edi_state column and set the default value is false (in pre-migration on account module)

---XML records in module 'account_edi'---
NEW ir.actions.act_window: account_edi.action_open_edi_documents
NEW ir.actions.act_window: account_edi.action_open_payment_edi_documents
NEW ir.cron: account_edi.ir_cron_edi_network
NEW ir.model.access: account_edi.access_account_edi_document_group_invoice
NEW ir.model.access: account_edi.access_account_edi_document_readonly
NEW ir.model.access: account_edi.access_account_edi_format_group_invoice
NEW ir.model.access: account_edi.access_account_edi_format_readonly
NEW ir.model.constraint: account_edi.constraint_account_edi_document_unique_edi_document_by_move_by_format
NEW ir.model.constraint: account_edi.constraint_account_edi_format_unique_code
NEW ir.ui.view: account_edi.account_invoice_send_inherit_account_wizard_form
NEW ir.ui.view: account_edi.view_account_journal_form_inherited
NEW ir.ui.view: account_edi.view_move_form_inherit
NEW ir.ui.view: account_edi.view_payment_form_inherit
NEW ir.ui.view: account_edi.view_tree_account_edi_document
# NOTHING TO DO

0 comments on commit be30008

Please sign in to comment.