From ef8147d698af38ee2f1bd78d9fb70f7eebdd8c12 Mon Sep 17 00:00:00 2001 From: Yolann Sabaux Date: Wed, 23 Mar 2022 14:26:05 +0000 Subject: [PATCH] [FIX] account: allow invoicing internal user/customer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce: 1. Install sales 2. Change Mitchell Admin contacts so that he is set in the "YourCompany" company 3. Create a quotation with Michell Admin as the customer 4. Put any item and confirm the quote 5. Receive the product and create the invoice 6. Go to the invoice, confirm the payment and register it Issue: -> Error with the journal id Cause: The payment is considered as internal payment and in https://github.com/odoo/odoo/blob/6d129783b53115927f664499207c8c800d40bca2/addons/account/models/account_payment.py#L886-L895 There is no destination_journal which violates not-null constraint Solution: Be sure that there is a destination journal when `is_internal_transfer` is computed. opw-2753819 closes odoo/odoo#87625 X-original-commit: 362d8cbf7724431672b8b73fb5f4682d4d2c3f66 Signed-off-by: William André (wan) Signed-off-by: yosa-odoo --- addons/account/models/account_payment.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index e0f0f35733c..790e620a442 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -397,10 +397,12 @@ class AccountPayment(models.Model): for pay in self: pay.partner_bank_id = pay.available_partner_bank_ids[:1]._origin - @api.depends('partner_id', 'destination_account_id', 'journal_id') + @api.depends('partner_id', 'journal_id', 'destination_journal_id') def _compute_is_internal_transfer(self): for payment in self: - payment.is_internal_transfer = payment.partner_id and payment.partner_id == payment.journal_id.company_id.partner_id + payment.is_internal_transfer = payment.partner_id \ + and payment.partner_id == payment.journal_id.company_id.partner_id \ + and payment.destination_journal_id @api.depends('payment_type', 'journal_id') def _compute_payment_method_line_id(self):