From 3e64cf1c3082d6d0c70a1e42e8be8ae193c0ea9f Mon Sep 17 00:00:00 2001 From: Flectra Community Bot Date: Sun, 1 Aug 2021 02:11:43 +0000 Subject: [PATCH] Automatic Update form OCA2FC Migrator --- README.md | 4 +- account_payment_order/__manifest__.py | 2 +- .../models/account_move_line.py | 1 + .../models/account_payment_order.py | 2 +- .../tests/test_payment_order_outbound.py | 79 +++++++++++++++++++ account_payment_partner/__manifest__.py | 2 +- .../models/account_move.py | 2 +- 7 files changed, 86 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6c50da6..0d6f01c 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,11 @@ addon | version | summary [account_payment_sale](account_payment_sale/) | 2.0.1.0.0| Adds payment mode on sale orders [account_banking_pain_base](account_banking_pain_base/) | 2.0.1.0.0| Base module for PAIN file generation [account_banking_mandate](account_banking_mandate/) | 2.0.1.1.0| Banking mandates -[account_payment_order](account_payment_order/) | 2.0.1.2.2| Account Payment Order +[account_payment_order](account_payment_order/) | 2.0.1.2.3| Account Payment Order [account_payment_purchase_stock](account_payment_purchase_stock/) | 2.0.1.0.0| Integrate Account Payment Purchase with Stock [account_banking_sepa_credit_transfer](account_banking_sepa_credit_transfer/) | 2.0.1.0.0| Create SEPA XML files for Credit Transfers [account_payment_mode](account_payment_mode/) | 2.0.1.0.1| Account Payment Mode -[account_payment_partner](account_payment_partner/) | 2.0.1.2.1| Adds payment mode on partners and invoices +[account_payment_partner](account_payment_partner/) | 2.0.1.2.2| Adds payment mode on partners and invoices [account_payment_order_return](account_payment_order_return/) | 2.0.1.0.1| Account Payment Order Return diff --git a/account_payment_order/__manifest__.py b/account_payment_order/__manifest__.py index a63b6f5..ed41889 100644 --- a/account_payment_order/__manifest__.py +++ b/account_payment_order/__manifest__.py @@ -8,7 +8,7 @@ { "name": "Account Payment Order", - "version": "2.0.1.2.2", + "version": "2.0.1.2.3", "license": "AGPL-3", "author": "ACSONE SA/NV, " "Therp BV, " diff --git a/account_payment_order/models/account_move_line.py b/account_payment_order/models/account_move_line.py index b55e288..6c373ef 100644 --- a/account_payment_order/models/account_move_line.py +++ b/account_payment_order/models/account_move_line.py @@ -90,6 +90,7 @@ class AccountMoveLine(models.Model): "communication_type": communication_type, "currency_id": currency_id, "amount_currency": amount_currency, + "date": False, # date is set when the user confirms the payment order } return vals diff --git a/account_payment_order/models/account_payment_order.py b/account_payment_order/models/account_payment_order.py index d817cfb..84df328 100644 --- a/account_payment_order/models/account_payment_order.py +++ b/account_payment_order/models/account_payment_order.py @@ -299,7 +299,7 @@ class AccountPaymentOrder(models.Model): payline.draft2open_payment_line_check() # Compute requested payment date if order.date_prefered == "due": - requested_date = payline.ml_maturity_date or today + requested_date = payline.ml_maturity_date or payline.date or today elif order.date_prefered == "fixed": requested_date = order.date_scheduled or today else: diff --git a/account_payment_order/tests/test_payment_order_outbound.py b/account_payment_order/tests/test_payment_order_outbound.py index 06f6f8d..44d5294 100644 --- a/account_payment_order/tests/test_payment_order_outbound.py +++ b/account_payment_order/tests/test_payment_order_outbound.py @@ -196,3 +196,82 @@ class TestPaymentOrderOutbound(TransactionCase): ) with self.assertRaises(ValidationError): outbound_order.date_scheduled = date.today() - timedelta(days=1) + + +def test_manual_line_and_manual_date(self): + # Create payment order + outbound_order = self.env["account.payment.order"].create( + { + "date_prefered": "due", + "payment_type": "outbound", + "payment_mode_id": self.mode.id, + "journal_id": self.journal.id, + "description": "order with manual line", + } + ) + self.assertEqual(len(outbound_order.payment_line_ids), 0) + # Create a manual payment order line with custom date + vals = { + "order_id": outbound_order.id, + "partner_id": self.env.ref("base.res_partner_4").id, + "partner_bank_id": self.env.ref("base.res_partner_4").bank_ids[0].id, + "communication": "manual line and manual date", + "currency_id": outbound_order.payment_mode_id.company_id.currency_id.id, + "amount_currency": 192.38, + "date": date.today() + timedelta(days=8), + } + self.env["account.payment.line"].create(vals) + + self.assertEqual(len(outbound_order.payment_line_ids), 1) + self.assertEqual( + outbound_order.payment_line_ids[0].date, date.today() + timedelta(days=8) + ) + + # Create a manual payment order line with normal date + vals = { + "order_id": outbound_order.id, + "partner_id": self.env.ref("base.res_partner_4").id, + "partner_bank_id": self.env.ref("base.res_partner_4").bank_ids[0].id, + "communication": "manual line", + "currency_id": outbound_order.payment_mode_id.company_id.currency_id.id, + "amount_currency": 200.38, + } + self.env["account.payment.line"].create(vals) + + self.assertEqual(len(outbound_order.payment_line_ids), 2) + self.assertEqual(outbound_order.payment_line_ids[1].date, False) + + # Open payment order + self.assertEqual(len(outbound_order.bank_line_ids), 0) + outbound_order.draft2open() + self.assertEqual(outbound_order.bank_line_count, 2) + self.assertEqual( + outbound_order.payment_line_ids[0].date, + outbound_order.payment_line_ids[0].bank_line_id.date, + ) + self.assertEqual(outbound_order.payment_line_ids[1].date, date.today()) + self.assertEqual(outbound_order.payment_line_ids[1].bank_line_id.date, date.today()) + # Generate and upload + outbound_order.open2generated() + outbound_order.generated2uploaded() + + self.assertEqual(outbound_order.state, "uploaded") + with self.assertRaises(UserError): + outbound_order.unlink() + + bank_line = outbound_order.bank_line_ids + + with self.assertRaises(UserError): + bank_line.unlink() + outbound_order.action_done_cancel() + self.assertEqual(outbound_order.state, "cancel") + outbound_order.cancel2draft() + outbound_order.unlink() + self.assertEqual( + len( + self.env["account.payment.order"].search( + [("description", "=", "order with manual line")] + ) + ), + 0, + ) diff --git a/account_payment_partner/__manifest__.py b/account_payment_partner/__manifest__.py index 21be414..e124050 100644 --- a/account_payment_partner/__manifest__.py +++ b/account_payment_partner/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Account Payment Partner", - "version": "2.0.1.2.1", + "version": "2.0.1.2.2", "category": "Banking addons", "license": "AGPL-3", "summary": "Adds payment mode on partners and invoices", diff --git a/account_payment_partner/models/account_move.py b/account_payment_partner/models/account_move.py index ed11503..5ab8e8f 100644 --- a/account_payment_partner/models/account_move.py +++ b/account_payment_partner/models/account_move.py @@ -149,5 +149,5 @@ class AccountMove(models.Model): if self.env.context.get("active_model") == "sale.order": # pragma: no cover virtual_move = self.new(vals) virtual_move._compute_partner_bank() - vals["partner_bank_id"] = virtual_move.partner_bank_id + vals["partner_bank_id"] = virtual_move.partner_bank_id.id return super().create(vals)