From 6b5859b8bc77de8734cec479b2e4f4422bf0f41a Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 16 Jun 2021 23:55:50 +0200 Subject: [PATCH] account_payment_order: remove done state (migration script provided) Don't set reference_type field on account.move required=True, because it causes a lot of problems in other modules that don't depend on this one. Setting it as required in the view is enough. --- account_payment_order/__manifest__.py | 2 +- .../migrations/14.0.1.3.0/pre-migration.py | 10 ++++++++++ account_payment_order/models/account_move.py | 1 - account_payment_order/models/account_payment_order.py | 8 +------- account_payment_order/views/account_payment_order.xml | 6 +++--- 5 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 account_payment_order/migrations/14.0.1.3.0/pre-migration.py diff --git a/account_payment_order/__manifest__.py b/account_payment_order/__manifest__.py index 2071b0e6a..b7f9cd10f 100644 --- a/account_payment_order/__manifest__.py +++ b/account_payment_order/__manifest__.py @@ -8,7 +8,7 @@ { "name": "Account Payment Order", - "version": "14.0.1.2.4", + "version": "14.0.1.3.0", "license": "AGPL-3", "author": "ACSONE SA/NV, " "Therp BV, " diff --git a/account_payment_order/migrations/14.0.1.3.0/pre-migration.py b/account_payment_order/migrations/14.0.1.3.0/pre-migration.py new file mode 100644 index 000000000..64171a7af --- /dev/null +++ b/account_payment_order/migrations/14.0.1.3.0/pre-migration.py @@ -0,0 +1,10 @@ +# Copyright 2021 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +def migrate(cr, version): + if not version: + return + + cr.execute( + "UPDATE account_payment_order SET state='uploaded' WHERE state='done'") diff --git a/account_payment_order/models/account_move.py b/account_payment_order/models/account_move.py index 1e6577ccc..7a7fe65bd 100644 --- a/account_payment_order/models/account_move.py +++ b/account_payment_order/models/account_move.py @@ -24,7 +24,6 @@ class AccountMove(models.Model): reference_type = fields.Selection( selection=[("none", "Free Reference"), ("structured", "Structured Reference")], string="Reference Type", - required=True, readonly=True, states={"draft": [("readonly", False)]}, default="none", diff --git a/account_payment_order/models/account_payment_order.py b/account_payment_order/models/account_payment_order.py index e9a400f7e..c241951c1 100644 --- a/account_payment_order/models/account_payment_order.py +++ b/account_payment_order/models/account_payment_order.py @@ -74,7 +74,6 @@ class AccountPaymentOrder(models.Model): ("open", "Confirmed"), ("generated", "File Generated"), ("uploaded", "File Uploaded"), - ("done", "Done"), ("cancel", "Cancel"), ], string="Status", @@ -106,7 +105,6 @@ class AccountPaymentOrder(models.Model): ) date_generated = fields.Date(string="File Generation Date", readonly=True) date_uploaded = fields.Date(string="File Upload Date", readonly=True) - date_done = fields.Date(string="Done Date", readonly=True) generated_user_id = fields.Many2one( comodel_name="res.users", string="Generated by", @@ -250,11 +248,7 @@ class AccountPaymentOrder(models.Model): if self.payment_mode_id.default_date_prefered: self.date_prefered = self.payment_mode_id.default_date_prefered - def action_done(self): - self.write({"date_done": fields.Date.context_today(self), "state": "done"}) - return True - - def action_done_cancel(self): + def action_uploaded_cancel(self): for move in self.move_ids: move.button_cancel() for move_line in move.line_ids: diff --git a/account_payment_order/views/account_payment_order.xml b/account_payment_order/views/account_payment_order.xml index e473156d3..61071a8c8 100644 --- a/account_payment_order/views/account_payment_order.xml +++ b/account_payment_order/views/account_payment_order.xml @@ -47,7 +47,7 @@ string="Cancel Payments" />