From 83da890e3596a250f1d880ab217701b03be02418 Mon Sep 17 00:00:00 2001
From: Julien Ortet <julien@le-filament.com>
Date: Thu, 7 Nov 2024 08:34:46 +0100
Subject: [PATCH] [add] handle del inj counter for auto sale price

---
 models/acc_operation.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/models/acc_operation.py b/models/acc_operation.py
index 111d1a0..400f617 100644
--- a/models/acc_operation.py
+++ b/models/acc_operation.py
@@ -338,12 +338,17 @@ class AccOperation(models.Model):
         """
         create sale price conf on new counter
         """
-        if counter_id.type in ["del"]:
+        if counter_id.type in ["del", "del_inj"]:
             inj_periods = self.env["acc.counter.period"].search(
                 [("acc_operation_id", "=", self.id), ("prm_type", "=", "injection")]
             )
 
             for inj_period in inj_periods:
+                if counter_id.type == "del_inj":
+                    price = self.sale_price_by_default
+                else:
+                    price = inj_period.sale_price
+
                 self.env["acc.price.conf"].create(
                     {
                         "start_date": inj_period.start_date,
-- 
GitLab