From 683cca734b2fa6d990fdf7bd085ad4c0e3d158a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Laporte?= <stephane.laporte@enercoop.org>
Date: Thu, 6 Feb 2025 13:27:06 +0100
Subject: [PATCH] =?UTF-8?q?[UPD]=20g=C3=A9n=C3=A9ration=20des=20factures?=
 =?UTF-8?q?=20de=20surplus.=20forcer=20la=20soci=C3=A9t=C3=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 models/account_move.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/models/account_move.py b/models/account_move.py
index 6bf6709..df7f2ec 100644
--- a/models/account_move.py
+++ b/models/account_move.py
@@ -124,6 +124,9 @@ class AccountMove(models.Model):
             if partner_id.bank_account_count == 1:
                 bank_id = partner_id.bank_ids[0].id
 
+        partner_for_company = partner_id.with_company(company_id.id)
+        payment_term_id = partner_for_company.property_payment_term_id.id or False
+
         account_move_id = self.env["account.move"].create(
             {
                 "acc_operation_id": operation_id,
@@ -134,9 +137,7 @@ class AccountMove(models.Model):
                 "start_date": start_date,
                 "end_date": end_date,
                 "currency_id": company_id.currency_id.id,
-                "invoice_payment_term_id": (
-                    partner_id.property_payment_term_id.id or False
-                ),
+                "invoice_payment_term_id": payment_term_id,
                 "partner_bank_id": bank_id,
             }
         )
-- 
GitLab