diff --git a/account_payment_order/README.rst b/account_payment_order/README.rst index 391730823..d3802964c 100644 --- a/account_payment_order/README.rst +++ b/account_payment_order/README.rst @@ -1,12 +1,37 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: License: AGPL-3 - ===================== Account Payment Order ===================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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/12.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-12-0/bank-payment-12-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/97/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + This module adds support for payment orders and debit orders. +**Table of contents** + +.. contents:: + :local: + Installation ============ @@ -21,7 +46,8 @@ This modules is part of the OCA/bank-payment suite. Configuration ============= -This module adds several options on Payment Modes, cf Invoicing/Accounting > Configuration > Management > Payment Modes. +This module adds several options on Payment Modes, cf Invoicing/Accounting > +Configuration > Management > Payment Modes. Usage ===== @@ -34,28 +60,29 @@ This module also adds a button *Add to Payment Order* on supplier invoices and a You can print a Payment order via the menu Invoicing/Accounting > Payments > Payment Orders and then select the payment oder to print. -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/173/11.0 - -Known issues / Roadmap -====================== - - * no known issues - 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. +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 `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* ACSONE SA/NV +* Therp BV +* Tecnativa +* Akretion + Contributors ------------- +~~~~~~~~~~~~ * Stéphane Bidoul * Alexis de Lattre @@ -73,15 +100,19 @@ Contributors * Meyomesse Gilles * Carlos Dauden -Maintainer ----------- +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. +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. -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. -To contribute to this module, please visit https://odoo-community.org. +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 124377839..62d9bf9f0 100644 --- a/account_payment_order/__manifest__.py +++ b/account_payment_order/__manifest__.py @@ -20,7 +20,6 @@ 'depends': [ 'account_payment_partner', 'base_iban', # for manual_bank_tranfer - 'document', # to see the attachments on payment.order ], 'data': [ 'security/payment_security.xml', diff --git a/account_payment_order/models/account_invoice.py b/account_payment_order/models/account_invoice.py index 2cda67b8d..d051f0913 100644 --- a/account_payment_order/models/account_invoice.py +++ b/account_payment_order/models/account_invoice.py @@ -13,6 +13,20 @@ class AccountInvoice(models.Model): payment_order_ok = fields.Boolean( compute="_compute_payment_order_ok", ) + # we restore this field from <=v11 for now for preserving behavior + # TODO: Check if we can remove it and base everything in something at + # payment mode or company level + reference_type = fields.Selection( + selection=[ + ('none', 'Free Reference'), + ('structured', 'Structured Reference'), + ], + string='Payment Reference', + required=True, + readonly=True, + states={'draft': [('readonly', False)]}, + default='none', + ) @api.depends('payment_mode_id', 'move_id', 'move_id.line_ids', 'move_id.line_ids.payment_mode_id') @@ -27,12 +41,6 @@ class AccountInvoice(models.Model): payment_mode = invoice.payment_mode_id invoice.payment_order_ok = payment_mode.payment_order_ok - @api.model - def _get_reference_type(self): - rt = super(AccountInvoice, self)._get_reference_type() - rt.append(('structured', _('Structured Reference'))) - return rt - @api.model def line_get_convert(self, line, part): """Copy supplier bank account from invoice to account move line""" @@ -103,12 +111,12 @@ class AccountInvoice(models.Model): line.create_payment_line_from_move_line(payorder) count += 1 if new_payorder: - inv.message_post(_( + inv.message_post(body=_( '%d payment lines added to the new draft payment ' 'order %s which has been automatically created.') % (count, payorder.name)) else: - inv.message_post(_( + inv.message_post(body=_( '%d payment lines added to the existing draft ' 'payment order %s.') % (count, payorder.name)) diff --git a/account_payment_order/models/account_payment_line.py b/account_payment_order/models/account_payment_line.py index b286a7541..9c7c20cd3 100644 --- a/account_payment_order/models/account_payment_line.py +++ b/account_payment_order/models/account_payment_line.py @@ -78,9 +78,10 @@ class AccountPaymentLine(models.Model): def _compute_amount_company_currency(self): for line in self: if line.currency_id and line.company_currency_id: - line.amount_company_currency = line.currency_id.with_context( - date=line.date).compute( - line.amount_currency, line.company_currency_id) + line.amount_company_currency = line.currency_id._convert( + line.amount_currency, line.company_currency_id, + line.company_id, line.date or fields.Date.today(), + ) @api.multi def payment_line_hashcode(self): diff --git a/account_payment_order/models/bank_payment_line.py b/account_payment_order/models/bank_payment_line.py index 4c9e509dd..5061adf5d 100644 --- a/account_payment_order/models/bank_payment_line.py +++ b/account_payment_order/models/bank_payment_line.py @@ -78,9 +78,10 @@ class BankPaymentLine(models.Model): for bline in self: amount_currency = sum( bline.mapped('payment_line_ids.amount_currency')) - amount_company_currency = bline.currency_id.with_context( - date=bline.date).compute( - amount_currency, bline.company_currency_id) + amount_company_currency = bline.currency_id._convert( + amount_currency, bline.company_currency_id, bline.company_id, + bline.date or fields.Date.today(), + ) bline.amount_currency = amount_currency bline.amount_company_currency = amount_company_currency diff --git a/account_payment_order/report/account_payment_order.py b/account_payment_order/report/account_payment_order.py index b82eba1f9..7957b1d21 100644 --- a/account_payment_order/report/account_payment_order.py +++ b/account_payment_order/report/account_payment_order.py @@ -7,6 +7,7 @@ from odoo.tools.misc import formatLang class AccountPaymentOrderReport(models.AbstractModel): _name = 'report.account_payment_order.print_account_payment_order_main' + _description = 'Technical model for printing payment order' @api.model def get_report_values(self, docids, data=None): diff --git a/account_payment_order/static/description/index.html b/account_payment_order/static/description/index.html new file mode 100644 index 000000000..4b3a94a41 --- /dev/null +++ b/account_payment_order/static/description/index.html @@ -0,0 +1,461 @@ + + + + + + +Account Payment Order + + + +
+

Account Payment Order

+ + +

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

+ +
+

Installation

+

This module depends on:

+
    +
  • account_payment_partner
  • +
  • base_iban
  • +
  • document
  • +
+

This modules is part of the OCA/bank-payment suite.

+
+
+

Configuration

+

This module adds several options on Payment Modes, cf Invoicing/Accounting > +Configuration > Management > Payment Modes.

+
+
+

Usage

+

You can create a Payment order via the menu Invoicing/Accounting > Payments > Payment Orders and then select the move lines to pay.

+

You can create a Debit order via the menu Invoicing/Accounting > Payments > Debit Orders and then select the move lines to debit.

+

This module also adds a button Add to Payment Order on supplier invoices and a button Add to Debit Order on customer invoices.

+

You can print a Payment order via the menu Invoicing/Accounting > Payments > Payment Orders and then select the payment oder to print.

+
+
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
  • Therp BV
  • +
  • Tecnativa
  • +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

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

+
+
+
+ + diff --git a/account_payment_order/test/data.yml b/account_payment_order/test/data.yml deleted file mode 100644 index c317b2059..000000000 --- a/account_payment_order/test/data.yml +++ /dev/null @@ -1,28 +0,0 @@ -- - I create a transfer account -- - !record {model: account.account, id: account_account_transfer0}: - code: TRANSF - name: Transfer - user_type: account.data_account_type_liability - type: other - reconcile: True -- - I create a transfer journal -- - !record {model: account.journal, id: transfer_journal0}: - name: Transfer journal - code: TR - type: general - company_id: base.main_company -- - I create a payment mode -- - !record {model: payment.mode, id: payment_mode0}: - name: Payment Mode Test - journal: account.bank_journal - bank_id: account_payment.partner_bank_1 - company_id: base.main_company - transfer_account_id: account_account_transfer0 - transfer_journal_id: transfer_journal0 - type: account_banking_payment_export.manual_bank_tranfer diff --git a/account_payment_order/test/test_partial_payment_refunded.yml b/account_payment_order/test/test_partial_payment_refunded.yml deleted file mode 100644 index 529a04e88..000000000 --- a/account_payment_order/test/test_partial_payment_refunded.yml +++ /dev/null @@ -1,134 +0,0 @@ -- - I create a supplier invoice -- - !record {model: account.invoice, id: account_invoice_supplier_refunded, view: account.invoice_supplier_form}: - check_total: 600.00 - partner_id: base.res_partner_12 - reference_type: none - type: in_invoice - account_id: account.a_pay - company_id: base.main_company - currency_id: base.EUR - invoice_line: - - account_id: account.a_expense - name: 'Some contact lenses' - price_unit: 600.00 - quantity: 1.0 - journal_id: account.expenses_journal -- - Make sure that the type is in_invoice -- - !python {model: account.invoice}: | - self.write(cr, uid, ref("account_invoice_supplier_refunded"), {'type': 'in_invoice'}) -- - I change the state of invoice to open by clicking Validate button -- - !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier_refunded} -- - I create a supplier refund for this invoice -- - !record {model: account.invoice, id: account_refund_supplier_refunded, view: account.invoice_supplier_form}: - check_total: 200.00 - partner_id: base.res_partner_12 - reference_type: none - type: in_refund - account_id: account.a_pay - company_id: base.main_company - currency_id: base.EUR - invoice_line: - - account_id: account.a_expense - name: 'Some contact lenses' - price_unit: 200.00 - quantity: 1.0 - journal_id: account.expenses_journal -- - Make sure that the type is in_refund -- - !python {model: account.invoice}: | - self.write(cr, uid, ref("account_refund_supplier_refunded"), {'type': 'in_refund'}) -- - I change the state of invoice to open by clicking Validate button -- - !workflow {model: account.invoice, action: invoice_open, ref: account_refund_supplier_refunded} -- - I create a payment order -- - !record {model: payment.order, id: partial_payment_order_1}: - mode: account_banking_payment_transfer.payment_mode0 - date_prefered: 'now' -- - I run the select move line to pay wizard -- - !python {model: payment.order.create}: | - context = { - "active_model": "payment.order", - "active_ids": [ref("partial_payment_order_1")], - "active_id": ref("partial_payment_order_1"), - } - wiz_id = self.create(cr, uid, {}, context=context) - self.search_entries(cr, uid, [wiz_id], context=context) - mline_ids = [] - invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account_invoice_supplier_refunded")) - for l in invoice.move_id.line_id: - if not l.debit and l.credit: - mline_ids.append(l.id) - break - refund = self.pool.get('account.invoice').browse(cr, uid, ref("account_refund_supplier_refunded")) - for l in refund.move_id.line_id: - if not l.credit and l.debit: - mline_ids.append(l.id) - break - self.write(cr, uid, [wiz_id], {'entries': [(6, 0, mline_ids)]}) - self.create_payment(cr, uid, [wiz_id], context=context) - pay_obj = self.pool.get('payment.order') - pay = pay_obj.browse(cr, uid, ref('partial_payment_order_1')) - assert len(pay.line_ids) == 2 -- - I confirm the payment order. -- - !workflow {model: payment.order, action: open, ref: partial_payment_order_1} -- - I check that payment order is now "Confirmed". -- - !assert {model: payment.order, id: partial_payment_order_1, severity: error, string: Payment Order should be 'Confirmed'.}: - - state == 'open' - - total == 400.0 -- - I create the wizard for paying the payment -- - !record {model: payment.manual, id: payment_manual_partial}: - create_date: !eval time.strftime('%Y-%m-%d') -- - I click OK -- - !python {model: payment.manual}: | - if context is None: - context = {} - context.update({'active_ids': [ref("partial_payment_order_1")]}) - self.button_ok(cr, uid, ref("payment_manual_partial"), context) -- - I check that the payment order is now "Sent". -- - !assert {model: payment.order, id: partial_payment_order_1, severity: error, string: Payment Order should be 'Sent'.}: - - state == 'sent' -- - I check that the invoice has payments associated -- - !assert {model: account.invoice, id: account_invoice_supplier_refunded, severity: error, string: payment_ids should be populated}: - - payment_ids -- - I check the content of the payment of the invoice -- - !python {model: account.invoice}: | - inv = self.browse(cr, uid, ref("account_invoice_supplier_refunded")) - payment1, payment2 = sorted(inv.payment_ids, key=lambda line: line.id) - assert payment1.debit == 200 - assert payment2.debit == 400 - assert inv.payment_ids[0].reconcile_id.id != False -- - I check that the invoice balance (residual) is now 0 and the state is paid -- - !assert {model: account.invoice, id: account_invoice_supplier_refunded, severity: error, string: Invoice residual should be 0.}: - - residual == 0 - - amount_total == 600 - - state == 'paid' diff --git a/account_payment_order/test/test_partial_payment_transfer.yml b/account_payment_order/test/test_partial_payment_transfer.yml deleted file mode 100644 index 2e7a05a7c..000000000 --- a/account_payment_order/test/test_partial_payment_transfer.yml +++ /dev/null @@ -1,252 +0,0 @@ -- - I create a supplier invoice -- - !record {model: account.invoice, id: account_invoice_supplier_partial, view: account.invoice_supplier_form}: - check_total: 1000.00 - partner_id: base.res_partner_12 - reference_type: none - type: in_invoice - account_id: account.a_pay - company_id: base.main_company - currency_id: base.EUR - invoice_line: - - account_id: account.a_expense - name: 'Some glasses' - price_unit: 1000.00 - quantity: 1.0 - journal_id: account.expenses_journal -- - Make sure that the type is in_invoice -- - !python {model: account.invoice}: | - self.write(cr, uid, ref("account_invoice_supplier_partial"), {'type': 'in_invoice'}) -- - I change the state of invoice to open by clicking Validate button -- - !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier_partial} -- - I create a payment order -- - !record {model: payment.order, id: partial_payment_order_2}: - mode: account_banking_payment_transfer.payment_mode0 - date_prefered: 'due' -- - I run the select move line to pay wizard -- - !python {model: payment.order.create}: | - context = { - "active_model": "payment.order", - "active_ids": [ref("partial_payment_order_2")], - "active_id": ref("partial_payment_order_2"), - } - wiz_id = self.create(cr, uid, {}, context=context) - self.search_entries(cr, uid, [wiz_id], context=context) - invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account_invoice_supplier_partial")) - move_line = invoice.move_id.line_id[0] - self.write(cr, uid, [wiz_id], {'entries': [(6, 0, [move_line.id])]}) - self.create_payment(cr, uid, [wiz_id], context=context) - pay_obj = self.pool.get('payment.order') - pay = pay_obj.browse(cr, uid, ref('partial_payment_order_2')) - assert pay.line_ids - assert pay.line_ids[0].amount_currency == 1000.0 -- - I change the amount paid to test the partial payment -- - !python {model: payment.order}: | - line_ids = self.browse(cr, uid, ref('partial_payment_order_2')).line_ids - line_to_change = line_ids[0] - assert line_to_change.amount_currency == 1000.00 - self.pool.get('payment.line').write(cr, uid, line_to_change.id, {'amount_currency':100}) -- - I confirm the payment order. -- - !workflow {model: payment.order, action: open, ref: partial_payment_order_2} -- - I check that payment order is now "Confirmed". -- - !assert {model: payment.order, id: partial_payment_order_2, severity: error, string: Payment Order should be 'Confirmed'.}: - - state == 'open' -- - I assume that the document is sent to the bank and validate. -- - !record {model: payment.manual, id: payment_manual_1}: - create_date: !eval time.strftime('%Y-%m-%d') -- - I click OK -- - !python {model: payment.manual}: | - if context is None: - context = {} - context.update({'active_ids': [ref("partial_payment_order_2")]}) - self.button_ok(cr, uid, ref("payment_manual_1"), context) -- - I check that the payment order is now "Sent". -- - !assert {model: payment.order, id: partial_payment_order_2, severity: error, string: Payment Order should be 'Sent'.}: - - state == 'sent' -- - I check that the invoice has payments associated -- - !assert {model: account.invoice, id: account_invoice_supplier_partial, severity: error, string: payment_ids should be populated}: - - payment_ids -- - I check the content of the payment of the invoice -- - !python {model: account.invoice}: | - inv = self.browse(cr, uid, ref("account_invoice_supplier_partial")) - assert round(inv.payment_ids[0].debit, 2) == 100 - assert inv.payment_ids[0].credit == 0 - assert not inv.payment_ids[0].reconcile_id.id - assert inv.payment_ids[0].reconcile_partial_id - sum_debit = 0.0 - sum_credit = 0.0 - for line in inv.payment_ids[0].reconcile_partial_id.line_partial_ids: - sum_debit += line.debit - sum_credit += line.credit - assert sum_debit == 100 - sum_credit == 1000 - assert inv.residual == 900 - assert inv.state == 'open' -- - I create a 2nd partial payment -- - !record {model: payment.order, id: partial_partial_payment_order_2}: - mode: account_banking_payment_transfer.payment_mode0 - date_prefered: 'due' -- - I search for the invoice entries to make the payment. -- - !python {model: payment.order.create}: | - context = { - "active_model": "payment.order", - "active_ids": [ref("partial_partial_payment_order_2")], - "active_id": ref("partial_partial_payment_order_2"), - } - wiz_id = self.create(cr, uid, {}, context=context) - self.search_entries(cr, uid, [wiz_id], context=context) - invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account_invoice_supplier_partial")) - for l in invoice.move_id.line_id: - if not l.debit and l.credit: - move_line = l - break - self.write(cr, uid, [wiz_id], {'entries': [(6,0,[move_line.id])]}) - self.create_payment(cr, uid, [wiz_id], context=context) - pay_obj = self.pool.get('payment.order') - pay = pay_obj.browse(cr, uid, ref('partial_partial_payment_order_2')) - assert len(pay.line_ids) == 1 - assert pay.line_ids[0].amount_currency == 900 -- - I change the amount paid to test the partial payment -- - !python {model: payment.order}: | - line_ids = self.browse(cr, uid, ref('partial_partial_payment_order_2')).line_ids - line_to_change = line_ids[0] - self.pool.get('payment.line').write(cr, uid, line_to_change.id, {'amount_currency':200}) -- - I confirm the payment order. -- - !workflow {model: payment.order, action: open, ref: partial_partial_payment_order_2} -- - I assume that the document is sent to the bank and validate. -- - !record {model: payment.manual, id: payment_manual_1}: - create_date: !eval time.strftime('%Y-%m-%d') -- - I click OK -- - !python {model: payment.manual}: | - if context is None: - context = {} - context.update({'active_ids': [ref("partial_partial_payment_order_2")]}) - self.button_ok(cr, uid, ref("payment_manual_1"), context) -- - I check that the payment order is now "Sent". -- - !assert {model: payment.order, id: partial_partial_payment_order_2, severity: error, string: Payment Order should be 'Sent'.}: - - state == 'sent' -- - I check the content of the payment of the invoice -- - !python {model: account.invoice}: | - inv = self.browse(cr, uid, ref("account_invoice_supplier_partial")) - assert len(inv.payment_ids) == 2 - assert inv.payment_ids[0].credit == 0 - assert not inv.payment_ids[0].reconcile_id.id - assert inv.payment_ids[0].reconcile_partial_id - sum_debit = 0.0 - sum_credit = 0.0 - for line in inv.payment_ids[0].reconcile_partial_id.line_partial_ids: - sum_debit += line.debit - sum_credit += line.credit - assert sum_debit == 300 - assert sum_credit == 1000 - assert inv.residual == 700 - assert inv.state == 'open' -- - I create the last partial payment for completing the payment -- - !record {model: payment.order, id: partial_partial_payment_order_3}: - mode: account_banking_payment_transfer.payment_mode0 - date_prefered: 'due' -- - I search for the invoice entries to make the payment. -- - !python {model: payment.order.create}: | - context = { - "active_model": "payment.order", - "active_ids": [ref("partial_partial_payment_order_3")], - "active_id": ref("partial_partial_payment_order_3"), - } - wiz_id = self.create(cr, uid, {}, context=context) - self.search_entries(cr, uid, [wiz_id], context=context) - invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account_invoice_supplier_partial")) - for l in invoice.move_id.line_id: - if not l.debit and l.credit: - move_line = l - break - self.write(cr, uid, [wiz_id], {'entries': [(6, 0, [move_line.id])]}) - self.create_payment(cr, uid, [wiz_id], context=context) - pay_obj = self.pool.get('payment.order') - pay = pay_obj.browse(cr, uid, ref('partial_partial_payment_order_3')) - assert len(pay.line_ids) == 1 - assert pay.line_ids[0].amount_currency == 700 -- - I confirm the payment order. -- - !workflow {model: payment.order, action: open, ref: partial_partial_payment_order_3} -- - I assume that the document is sent to the bank and validate. -- - !record {model: payment.manual, id: payment_manual_3}: - create_date: !eval time.strftime('%Y-%m-%d') -- - I click OK -- - !python {model: payment.manual}: | - if context is None: - context = {} - context.update({'active_ids': [ref("partial_partial_payment_order_3")]}) - self.button_ok(cr, uid, ref("payment_manual_3"), context) -- - I check that the payment order is now "Sent". -- - !assert {model: payment.order, id: partial_partial_payment_order_3, severity: error, string: Payment Order should be 'Sent'.}: - - state == 'sent' -- - I check the content of the payment of the invoice -- - !python {model: account.invoice}: | - inv = self.browse(cr, uid, ref("account_invoice_supplier_partial")) - assert len(inv.payment_ids) == 3 - assert inv.payment_ids[0].credit == 0 - assert inv.payment_ids[0].reconcile_id.id - #assert not inv.payment_ids[0].reconcile_partial_id ?? should we remove it? - sum_debit = 0.0 - sum_credit = 0.0 - for line in inv.payment_ids: - sum_debit += line.debit - sum_credit += line.credit - assert sum_debit == 1000 - assert sum_credit == 0 - assert inv.residual == 0 - assert inv.state == 'paid' diff --git a/account_payment_order/test/test_payment_method.yml b/account_payment_order/test/test_payment_method.yml deleted file mode 100644 index 4a74dd895..000000000 --- a/account_payment_order/test/test_payment_method.yml +++ /dev/null @@ -1,159 +0,0 @@ -- - I create a supplier invoice -- - !record {model: account.invoice, id: account_invoice_supplier0, view: account.invoice_supplier_form}: - check_total: 1005.55 - partner_id: base.res_partner_4 - reference_type: none - type: in_invoice - account_id: account.a_pay - company_id: base.main_company - currency_id: base.EUR - invoice_line: - - account_id: account.a_expense - name: 'Some expenses' - price_unit: 450.0 - quantity: 1.0 - - account_id: account.a_expense - name: 'Some other expenses' - price_unit: 555.55 - quantity: 1.0 - journal_id: account.expenses_journal -- - Make sure that the type is in_invoice -- - !python {model: account.invoice}: | - self.write(cr, uid, ref("account_invoice_supplier0"), {'type': 'in_invoice'}) -- - I change the state of invoice to open by clicking Validate button -- - !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier0} -- - I check that the invoice state is now "Open" -- - !assert {model: account.invoice, id: account_invoice_supplier0}: - - state == 'open' - - type == 'in_invoice' -- - I create a payment order -- - !record {model: payment.order, id: payment_order_0}: - mode: account_banking_payment_transfer.payment_mode0 - date_prefered: 'due' -- - I run the select move line to pay wizard -- - !python {model: payment.order.create}: | - context = { - "active_model": "payment.order", - "active_ids": [ref("payment_order_0")], - "active_id": ref("payment_order_0"), - } - wiz_id = self.create(cr, uid, {}, context=context) - self.search_entries(cr, uid, [wiz_id], context=context) - invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account_invoice_supplier0")) - entries = [] - for move_line in invoice.move_id.line_id: - if move_line.credit and not move_line.debit: - entries.append((6, 0, [move_line.id])) - self.write(cr, uid, [wiz_id], {'entries': entries}) - self.create_payment(cr, uid, [wiz_id], context=context) - pay_obj = self.pool.get('payment.order') - pay = pay_obj.browse(cr, uid, ref('payment_order_0')) - for line in pay.line_ids: - assert line.amount != 0.0 -- - I confirm the payment order. -- - !workflow {model: payment.order, action: open, ref: payment_order_0} -- - I check that payment order is now "Confirmed". -- - !assert {model: payment.order, id: payment_order_0, severity: error, string: Payment Order should be 'Confirmed'.}: - - state == 'open' -- - I create the wizard for paying the payment -- - !record {model: payment.manual, id: payment_manual_0}: - create_date: !eval time.strftime('%Y-%m-%d') -- - I click OK -- - !python {model: payment.manual}: | - if context is None: - context = {} - context.update({'active_ids': [ref("payment_order_0")]}) - self.button_ok(cr, uid, ref("payment_manual_0"), context) -- - I check that the payment order is now "Sent". -- - !assert {model: payment.order, id: payment_order_0, severity: error, string: Payment Order should be 'Sent'.}: - - state == 'sent' -- - I check that the invoice has payments associated -- - !assert {model: account.invoice, id: account_invoice_supplier0, severity: error, string: payment_ids should be populated}: - - payment_ids -- - I check the content of the payment of the invoice -- - !python {model: account.invoice}: | - inv = self.browse(cr, uid, ref("account_invoice_supplier0")) - assert round(inv.payment_ids[0].debit, 2) == 1005.55 - assert inv.payment_ids[0].credit == 0 - assert inv.payment_ids[0].reconcile_id.id != False - assert inv.payment_ids[0].reconcile_ref != False - assert inv.state == 'paid' -- - I create the bank statement to reconcile the transfer account move -- - !record {model: account.bank.statement, id: bank_statement_0}: - name: BK test - balance_end_real: 0.0 - balance_start: 0.0 - date: !eval time.strftime('%Y-%m-%d') - journal_id: account.bank_journal -- - I create bank statement line -- - !python {model: account.bank.statement.line}: | - vals = { - 'amount': -1005.55, - 'partner_id': ref('base.res_partner_4'), - 'statement_id': ref('bank_statement_0'), - 'name': 'Pay invoice', - 'journal_id': ref("account.bank_journal"), - } - line_id = self.create(cr, uid, vals) - assert line_id, "Account bank statement line has not been created" -- - I reconcile the move transfer (not the invoice) with the payment. -- - !python {model: account.bank.statement}: | - inv_obj = self.pool.get('account.invoice') - statement_obj = self.pool.get('account.bank.statement.line') - transfer_entry = inv_obj.browse(cr, uid, ref("account_invoice_supplier0")).payment_ids[0].move_id - for line in transfer_entry.line_id: - if not line.reconcile_id and line.credit: - counterpart_move_line = line - break - browse_payment = self.browse(cr, uid, ref("bank_statement_0")) - for line in browse_payment.line_ids: - statement_obj.process_reconciliation(cr, uid, line.id, [{ - 'counterpart_move_line_id': counterpart_move_line.id, - 'credit':0, - 'debit': counterpart_move_line.credit, - 'name': line.name, - }]) - self.write(cr, uid, ref("bank_statement_0"), {'balance_end_real': -1005.55}) - self.button_confirm_bank(cr, uid, ref("bank_statement_0")) -- - I check that the bank statement is confirm -- - !assert {model: account.bank.statement, id: bank_statement_0, severity: error, string: Bank Statement should be confirm}: - - state == 'confirm' -- - I check that the payment is done -- - !assert {model: payment.order, id: payment_order_0, severity: error, string: Payment Order should be done}: - - state == 'done' diff --git a/account_payment_order/views/account_invoice_view.xml b/account_payment_order/views/account_invoice_view.xml index c5a2909ef..74caa7ad3 100644 --- a/account_payment_order/views/account_invoice_view.xml +++ b/account_payment_order/views/account_invoice_view.xml @@ -26,6 +26,9 @@ + + +