diff --git a/account_payment_order/README.rst b/account_payment_order/README.rst index 13cf5b16d..b85a3be49 100644 --- a/account_payment_order/README.rst +++ b/account_payment_order/README.rst @@ -14,13 +14,13 @@ Account Payment Order :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github - :target: https://github.com/OCA/bank-payment/tree/13.0/account_payment_order + :target: https://github.com/OCA/bank-payment/tree/14.0/account_payment_order :alt: OCA/bank-payment .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/bank-payment-13-0/bank-payment-13-0-account_payment_order + :target: https://translation.odoo-community.org/projects/bank-payment-14-0/bank-payment-14-0-account_payment_order :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/173/13.0 + :target: https://runbot.odoo-community.org/runbot/173/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -66,7 +66,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -103,6 +103,9 @@ Contributors * Raf Ven * Andrea Stirpe +* `Jarsa `_: + + * Alan Ramos Maintainers ~~~~~~~~~~~ @@ -117,6 +120,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/bank-payment `_ project on GitHub. +This module is part of the `OCA/bank-payment `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_payment_order/__manifest__.py b/account_payment_order/__manifest__.py index 77abc729f..ec0d6cc48 100644 --- a/account_payment_order/__manifest__.py +++ b/account_payment_order/__manifest__.py @@ -8,7 +8,7 @@ { "name": "Account Payment Order", - "version": "13.0.1.4.1", + "version": "14.0.1.0.0", "license": "AGPL-3", "author": "ACSONE SA/NV, " "Therp BV, " diff --git a/account_payment_order/models/account_move.py b/account_payment_order/models/account_move.py index eb11c6fd7..09a7da04f 100644 --- a/account_payment_order/models/account_move.py +++ b/account_payment_order/models/account_move.py @@ -116,9 +116,9 @@ class AccountMove(models.Model): ) % (count, payorder.name) ) - action = self.env["ir.actions.act_window"].for_xml_id( - "account_payment_order", - "account_payment_order_%s_action" % action_payment_type, + action = self.env["ir.actions.act_window"]._for_xml_id( + "account_payment_order.account_payment_order_%s_action" + % action_payment_type, ) if len(result_payorder_ids) == 1: action.update( diff --git a/account_payment_order/models/account_move_line.py b/account_payment_order/models/account_move_line.py index 32c6b1e89..11ee45562 100644 --- a/account_payment_order/models/account_move_line.py +++ b/account_payment_order/models/account_move_line.py @@ -26,13 +26,11 @@ class AccountMoveLine(models.Model): string="Payment lines", ) - @api.depends( - "move_id", "move_id.invoice_partner_bank_id", "move_id.payment_mode_id" - ) + @api.depends("move_id", "move_id.partner_bank_id", "move_id.payment_mode_id") def _compute_partner_bank_id(self): for ml in self: if ( - ml.move_id.type in ("in_invoice", "in_refund") + ml.move_id.move_type in ("in_invoice", "in_refund") and not ml.reconciled and ml.payment_mode_id.payment_order_ok and ml.account_id.internal_type in ("receivable", "payable") @@ -41,7 +39,7 @@ class AccountMoveLine(models.Model): for p_state in ml.payment_line_ids.mapped("state") ) ): - ml.partner_bank_id = ml.move_id.invoice_partner_bank_id.id + ml.partner_bank_id = ml.move_id.partner_bank_id.id else: ml.partner_bank_id = ml.partner_bank_id @@ -60,11 +58,11 @@ class AccountMoveLine(models.Model): communication_type = ref2comm_type[self.move_id.reference_type] else: if ( - self.move_id.type in ("in_invoice", "in_refund") + self.move_id.move_type in ("in_invoice", "in_refund") and self.move_id.ref ): communication = self.move_id.ref - elif "out" in self.move_id.type: + elif "out" in self.move_id.move_type: # Force to only put invoice number here communication = self.move_id.name if self.currency_id: diff --git a/account_payment_order/models/account_payment.py b/account_payment_order/models/account_payment.py index 1ce0d1072..6decc5e98 100644 --- a/account_payment_order/models/account_payment.py +++ b/account_payment_order/models/account_payment.py @@ -7,22 +7,33 @@ from odoo import api, models class AccountPayment(models.Model): _inherit = "account.payment" - def _compute_journal_domain_and_types(self): - res = super(AccountPayment, self)._compute_journal_domain_and_types() - journal_domain = res.get("domain", []) - if self.payment_type == "inbound": - journal_domain.append(("inbound_payment_order_only", "=", False)) - else: - journal_domain.append(("outbound_payment_order_only", "=", False)) - res["domain"] = journal_domain - return res + def _get_default_journal(self): + res = super()._get_default_journal() + return res.filtered(lambda journal: not journal.inbound_payment_order_only) - @api.onchange("journal_id") - def _onchange_journal(self): - res = super(AccountPayment, self)._onchange_journal() - domains = res.get("domain") - if not domains: - return res - if domains.get("payment_method_id"): - domains["payment_method_id"].append(("payment_order_only", "!=", True)) + @api.depends( + "payment_type", + "journal_id.inbound_payment_method_ids", + "journal_id.outbound_payment_method_ids", + ) + def _compute_payment_method_fields(self): + res = super()._compute_payment_method_fields() + for pay in self: + if pay.payment_type == "inbound": + pay.available_payment_method_ids = ( + pay.journal_id.inbound_payment_method_ids.filtered( + lambda m: not m.payment_order_only + ) + ) + else: + pay.available_payment_method_ids = ( + pay.journal_id.outbound_payment_method_ids.filtered( + lambda m: not m.payment_order_only + ) + ) + + pay.hide_payment_method = ( + len(pay.available_payment_method_ids) == 1 + and pay.available_payment_method_ids.code == "manual" + ) return res diff --git a/account_payment_order/models/account_payment_order.py b/account_payment_order/models/account_payment_order.py index b7816bcd0..5402992dc 100644 --- a/account_payment_order/models/account_payment_order.py +++ b/account_payment_order/models/account_payment_order.py @@ -21,7 +21,7 @@ class AccountPaymentOrder(models.Model): comodel_name="account.payment.mode", required=True, ondelete="restrict", - track_visibility="onchange", + tracking=True, states={"draft": [("readonly", False)]}, ) payment_type = fields.Selection( @@ -56,7 +56,7 @@ class AccountPaymentOrder(models.Model): ondelete="restrict", readonly=True, states={"draft": [("readonly", False)]}, - track_visibility="onchange", + tracking=True, ) # The journal_id field is only required at confirm step, to # allow auto-creation of payment order from invoice @@ -78,7 +78,7 @@ class AccountPaymentOrder(models.Model): readonly=True, copy=False, default="draft", - track_visibility="onchange", + tracking=True, ) date_prefered = fields.Selection( selection=[ @@ -89,7 +89,7 @@ class AccountPaymentOrder(models.Model): string="Payment Execution Date Type", required=True, default="due", - track_visibility="onchange", + tracking=True, readonly=True, states={"draft": [("readonly", False)]}, ) @@ -97,7 +97,7 @@ class AccountPaymentOrder(models.Model): string="Payment Execution Date", readonly=True, states={"draft": [("readonly", False)]}, - track_visibility="onchange", + tracking=True, help="Select a requested date of execution if you selected 'Due Date' " "as the Payment Execution Date Type.", ) @@ -458,7 +458,7 @@ class AccountPaymentOrder(models.Model): vals.update({"date_maturity": bank_lines[0].date}) if self.payment_mode_id.offsetting_account == "bank_account": - account_id = self.journal_id.default_debit_account_id.id + account_id = self.journal_id.default_account_id.id elif self.payment_mode_id.offsetting_account == "transfer_account": account_id = self.payment_mode_id.transfer_account_id.id partner_id = False @@ -537,9 +537,9 @@ class AccountPaymentOrder(models.Model): am_obj = self.env["account.move"] mvals = self._prepare_move(blines) move = am_obj.create(mvals) - blines.reconcile_payment_lines() if post_move: - move.post() + move.action_post() + blines.reconcile_payment_lines() def _prepare_trf_moves(self): """ diff --git a/account_payment_order/readme/CONTRIBUTORS.rst b/account_payment_order/readme/CONTRIBUTORS.rst index b5827224e..4b2f30622 100644 --- a/account_payment_order/readme/CONTRIBUTORS.rst +++ b/account_payment_order/readme/CONTRIBUTORS.rst @@ -17,3 +17,6 @@ * Raf Ven * Andrea Stirpe +* `Jarsa `_: + + * Alan Ramos diff --git a/account_payment_order/report/account_payment_order.xml b/account_payment_order/report/account_payment_order.xml index c286303e1..56ec2269f 100644 --- a/account_payment_order/report/account_payment_order.xml +++ b/account_payment_order/report/account_payment_order.xml @@ -99,7 +99,7 @@ diff --git a/account_payment_order/report/print_account_payment_order.xml b/account_payment_order/report/print_account_payment_order.xml index 546df92fd..00793f9ec 100644 --- a/account_payment_order/report/print_account_payment_order.xml +++ b/account_payment_order/report/print_account_payment_order.xml @@ -3,12 +3,16 @@ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - + + ayment Order + account.payment.order + qweb-pdf + account_payment_order.print_account_payment_order_main + account_payment_order.print_account_payment_order_main + + diff --git a/account_payment_order/security/ir.model.access.csv b/account_payment_order/security/ir.model.access.csv index 82653a55f..11512c93f 100644 --- a/account_payment_order/security/ir.model.access.csv +++ b/account_payment_order/security/ir.model.access.csv @@ -4,3 +4,5 @@ access_account_payment_line,Full access on account.payment.line to Payment Manag access_bank_payment_line,Full access on bank.payment.line to Payment Manager,model_bank_payment_line,group_account_payment,1,1,1,1 base.access_res_partner_bank_group_partner_manager,Full access on res.partner.bank to Account Payment group,base.model_res_partner_bank,group_account_payment,1,1,1,1 base.access_res_bank_group_partner_manager,Full access on res.bank to Account Payment group,base.model_res_bank,group_account_payment,1,1,1,1 +access_account_payment_line_create,access_account_payment_line_create,model_account_payment_line_create,group_account_payment,1,1,1,1 +access_account_invoice_payment_line_multi,access_account_invoice_payment_line_multi,model_account_invoice_payment_line_multi,group_account_payment,1,1,1,1 diff --git a/account_payment_order/static/description/index.html b/account_payment_order/static/description/index.html index ca3f8ad11..4b2755629 100644 --- a/account_payment_order/static/description/index.html +++ b/account_payment_order/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/bank-payment Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/bank-payment Translate me on Weblate Try me on Runbot

This module adds support for payment orders and debit orders.

Table of contents

@@ -411,7 +411,7 @@ Configuration > Management > Payment Modes.

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -448,6 +448,10 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
  • Andrea Stirpe <a.stirpe@onestein.nl>
  • +
  • Jarsa: +
  • @@ -457,7 +461,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    -

    This module is part of the OCA/bank-payment project on GitHub.

    +

    This module is part of the OCA/bank-payment project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/account_payment_order/tests/test_account_payment.py b/account_payment_order/tests/test_account_payment.py index b1f4f15ef..435134798 100644 --- a/account_payment_order/tests/test_account_payment.py +++ b/account_payment_order/tests/test_account_payment.py @@ -66,54 +66,32 @@ class TestAccountPayment(SavepointCase): {"journal_id": self.bank_journal.id, "payment_type": "inbound", "amount": 1} ) # check journals - journal_res = new_account_payment._compute_journal_domain_and_types() - journal_domain = journal_res.get("domain") - self.assertTrue(journal_domain) - journals = self.account_journal_model.search(journal_domain) + journals = new_account_payment._get_default_journal() self.assertIn(self.bank_journal, journals) # check payment methods - payment_method_res = new_account_payment._onchange_journal() - payment_method_domain = payment_method_res.get("domain", {}).get( - "payment_method_id" - ) - self.assertTrue(payment_method_domain) - payment_methods = self.payment_method_model.search(payment_method_domain) - self.assertIn(self.inbound_payment_method_01, payment_methods) - self.assertIn(self.inbound_payment_method_02, payment_methods) + payment_methods = new_account_payment.available_payment_method_ids.ids + self.assertIn(self.inbound_payment_method_01.id, payment_methods) + self.assertIn(self.inbound_payment_method_02.id, payment_methods) # Set one payment method of the bank journal 'payment order only' self.inbound_payment_method_01.payment_order_only = True # check journals - journal_res = new_account_payment._compute_journal_domain_and_types() - journal_domain = journal_res.get("domain") - self.assertTrue(journal_domain) - journals = self.account_journal_model.search(journal_domain) + journals = new_account_payment._get_default_journal() self.assertIn(self.bank_journal, journals) # check payment methods - payment_method_res = new_account_payment._onchange_journal() - payment_method_domain = payment_method_res.get("domain", {}).get( - "payment_method_id" - ) - self.assertTrue(payment_method_domain) - payment_methods = self.payment_method_model.search(payment_method_domain) - self.assertNotIn(self.inbound_payment_method_01, payment_methods) - self.assertIn(self.inbound_payment_method_02, payment_methods) + new_account_payment._compute_payment_method_fields() + payment_methods = new_account_payment.available_payment_method_ids.ids + self.assertNotIn(self.inbound_payment_method_01.id, payment_methods) + self.assertIn(self.inbound_payment_method_02.id, payment_methods) # Set all payment methods of the bank journal 'payment order only' self.inbound_payment_method_02.payment_order_only = True self.assertTrue(self.inbound_payment_method_01.payment_order_only) self.assertTrue(self.inbound_payment_method_02.payment_order_only) self.assertTrue(self.bank_journal.inbound_payment_order_only) # check journals - journal_res = new_account_payment._compute_journal_domain_and_types() - journal_domain = journal_res.get("domain") - self.assertTrue(journal_domain) - journals = self.account_journal_model.search(journal_domain) + journals = new_account_payment._get_default_journal() self.assertNotIn(self.bank_journal, journals) # check payment methods - payment_method_res = new_account_payment._onchange_journal() - payment_method_domain = payment_method_res.get("domain", {}).get( - "payment_method_id" - ) - self.assertTrue(payment_method_domain) - payment_methods = self.payment_method_model.search(payment_method_domain) - self.assertNotIn(self.inbound_payment_method_01, payment_methods) - self.assertNotIn(self.inbound_payment_method_02, payment_methods) + new_account_payment._compute_payment_method_fields() + payment_methods = new_account_payment.available_payment_method_ids.ids + self.assertNotIn(self.inbound_payment_method_01.id, payment_methods) + self.assertNotIn(self.inbound_payment_method_02.id, payment_methods) diff --git a/account_payment_order/tests/test_payment_mode.py b/account_payment_order/tests/test_payment_mode.py index 474e626c4..be60a17ac 100644 --- a/account_payment_order/tests/test_payment_mode.py +++ b/account_payment_order/tests/test_payment_mode.py @@ -88,7 +88,7 @@ class TestPaymentMode(TransactionCase): self.assertFalse(self.payment_mode_c1.move_option) def test_onchange_offsetting_account(self): - self.payment_mode_c1.offsetting = "bank_account" + self.payment_mode_c1.offsetting_account = "bank_account" self.payment_mode_c1.offsetting_account_change() self.assertFalse(self.payment_mode_c1.transfer_account_id) diff --git a/account_payment_order/tests/test_payment_order_inbound.py b/account_payment_order/tests/test_payment_order_inbound.py index 66ef929dd..b3efd9e1d 100644 --- a/account_payment_order/tests/test_payment_order_inbound.py +++ b/account_payment_order/tests/test_payment_order_inbound.py @@ -53,7 +53,7 @@ class TestPaymentOrderInboundBase(SavepointCase): def _create_customer_invoice(self): with Form( - self.env["account.move"].with_context(default_type="out_invoice") + self.env["account.move"].with_context(default_move_type="out_invoice") ) as invoice_form: invoice_form.partner_id = self.env.ref("base.res_partner_4") with invoice_form.invoice_line_ids.new() as invoice_line_form: @@ -86,8 +86,6 @@ class TestPaymentOrderInbound(TestPaymentOrderInboundBase): bank_journal = self.env["account.journal"].search( [("type", "=", "bank")], limit=1 ) - # Set journal to allow cancelling entries - bank_journal.update_posted = True payment_order.write({"journal_id": bank_journal.id}) diff --git a/account_payment_order/tests/test_payment_order_outbound.py b/account_payment_order/tests/test_payment_order_outbound.py index 72dac74cf..e69dfa5c8 100644 --- a/account_payment_order/tests/test_payment_order_outbound.py +++ b/account_payment_order/tests/test_payment_order_outbound.py @@ -45,7 +45,7 @@ class TestPaymentOrderOutbound(TransactionCase): invoice = self.env["account.move"].create( { "partner_id": self.env.ref("base.res_partner_4").id, - "type": "in_invoice", + "move_type": "in_invoice", "payment_mode_id": self.env.ref( "account_payment_mode.payment_mode_outbound_ct1" ).id, @@ -155,8 +155,6 @@ class TestPaymentOrderOutbound(TransactionCase): bank_journal = self.env["account.journal"].search( [("type", "=", "bank")], limit=1 ) - # Set journal to allow cancelling entries - bank_journal.update_posted = True payment_order.write({"journal_id": bank_journal.id}) diff --git a/account_payment_order/views/account_invoice_view.xml b/account_payment_order/views/account_invoice_view.xml index 5b162ebb9..7e04be0b1 100644 --- a/account_payment_order/views/account_invoice_view.xml +++ b/account_payment_order/views/account_invoice_view.xml @@ -24,7 +24,7 @@ attrs="{'invisible': ['|', '|', ('payment_order_ok', '=', False), ('state', '!=', 'posted'), - ('type', 'not in', ('out_invoice', 'out_refund')) + ('move_type', 'not in', ('out_invoice', 'out_refund')) ]}" /> @@ -48,17 +48,19 @@ required="1" nolabel="1" attrs="{'readonly':[('state','!=','draft')], - 'invisible': [('type', 'not in', ('out_invoice', 'out_refund'))]}" + 'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund'))]}" /> - + model="ir.actions.act_window" + > + Add to Payment/Debit Order + account.invoice.payment.line.multi + form + new + + diff --git a/account_payment_order/wizard/account_payment_line_create.py b/account_payment_order/wizard/account_payment_line_create.py index 7ca407f85..9af6bbe67 100644 --- a/account_payment_order/wizard/account_payment_line_create.py +++ b/account_payment_order/wizard/account_payment_line_create.py @@ -90,7 +90,7 @@ class AccountPaymentLineCreate(models.TransientModel): if self.invoice: domain.append( ( - "move_id.type", + "move_id.move_type", "in", ("in_invoice", "out_invoice", "in_refund", "out_refund"), )