diff --git a/__manifest__.py b/__manifest__.py index ebe743b9099775dfa0d775e8468de6ea0dd4fe14..589ef5d5a498e712e338c467e6ee122c13bfe54e 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -1,7 +1,7 @@ { "name": "3A Dentaire - Account", "summary": "Modification des modules account pour 3A", - "version": "12.1.1.0", + "version": "13.0.1.1.0", "author": "Le Filament", "license": "AGPL-3", "application": False, @@ -10,11 +10,11 @@ "account", "sale" ], "data": [ - 'security/security_rules.xml', - "views/account_bank_statement.xml", - "views/account_move_line.xml", - "views/account_views.xml", - "views/sale_views.xml", - "views/menu.xml", + #'security/security_rules.xml', + #"views/account_bank_statement.xml", + #"views/account_move_line.xml", + #"views/account_views.xml", + #"views/sale_views.xml", + #"views/menu.xml", ] } diff --git a/migrations/13.0.1.1.0/post-migration.py b/migrations/13.0.1.1.0/post-migration.py new file mode 100644 index 0000000000000000000000000000000000000000..311ac97bfc18056488f44a01421eb0e652c4974a --- /dev/null +++ b/migrations/13.0.1.1.0/post-migration.py @@ -0,0 +1,33 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade +from psycopg2 import sql + + +def update_account_move_user_rel_table(cr): + table = "openupgrade_legacy_13_0_aiu_rel" + openupgrade.logged_query( + cr, sql.SQL( + """INSERT INTO account_move_res_users_rel + (invoice_id, user_id) + SELECT am.id, user_id + FROM {} rel + JOIN account_move am ON am.old_invoice_id = rel.invoice_id""" + ).format(sql.Identifier(table)) + ) + +def update_account_move_user_provider_id(cr): + openupgrade.logged_query( + cr, """ + UPDATE account_move am + SET user_provider_id = ai.user_provider_id + FROM account_invoice ai + WHERE am.old_invoice_id = ai.id + """ + ) + + +@openupgrade.migrate(use_env=True) +def migrate(env, version): + update_account_move_user_rel_table(env.cr) + update_account_move_user_provider_id(env.cr) diff --git a/migrations/13.0.1.1.0/pre-migration.py b/migrations/13.0.1.1.0/pre-migration.py new file mode 100644 index 0000000000000000000000000000000000000000..3e7e9ea28b515955d75018ccf3d34e23d27ea4a1 --- /dev/null +++ b/migrations/13.0.1.1.0/pre-migration.py @@ -0,0 +1,12 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + +_tables_rename = [ + ("account_invoice_res_users_rel", "openupgrade_legacy_13_0_aiu_rel") +] + + +@openupgrade.migrate(use_env=True) +def migrate(env, version): + openupgrade.rename_tables(env.cr, _tables_rename) diff --git a/models/account.py b/models/account.py index b4d7895125acbb6816ef2e53de2352dcb3727e37..1176c8e8dbb204cc87c807ad710f0cf1ef824bf7 100644 --- a/models/account.py +++ b/models/account.py @@ -5,7 +5,7 @@ from odoo import fields, models class AccountInvoice(models.Model): - _inherit = "account.invoice" + _inherit = "account.move" # ------------------------------------------------------ # Fields declaration diff --git a/models/res_users.py b/models/res_users.py index d89b863488e4ca2c1323eec43bf8e267a8618d6e..431db1642bf7f143e0ae8496552c1ab372461097 100644 --- a/models/res_users.py +++ b/models/res_users.py @@ -17,7 +17,7 @@ class ResUsers(models.Model): string='Commandes', copy=False) invoice_second_ids = fields.Many2many( - comodel_name='account.invoice', + comodel_name='account.move', column1='user_id', column2='invoice_id', string='Factures', diff --git a/models/sale.py b/models/sale.py index ad43f33cb74f0c72b7d1b039afd2fef7c10d1aef..fbf63c1d316a32a34b81395ed3d45f4d936cc403 100644 --- a/models/sale.py +++ b/models/sale.py @@ -50,7 +50,6 @@ class SaleOrder(models.Model): # ------------------------------------------------------ # Business methods # ------------------------------------------------------ - @api.multi def _prepare_invoice(self): values = super(SaleOrder, self)._prepare_invoice() values.update({