diff --git a/sale_order_batch/models/sale_order.py b/sale_order_batch/models/sale_order.py
index 69a3c7b..d40a18a 100644
--- a/sale_order_batch/models/sale_order.py
+++ b/sale_order_batch/models/sale_order.py
@@ -34,7 +34,7 @@ class SaleOrder(models.Model):
for sale_order in self:
company = sale_order.company_id
sale_order = sale_order.with_company(company)
- if not sale_order.batch_id and sale_order.state in ["draft", "sent"]:
+ if not sale_order.batch_id and sale_order.state in ["draft"]:
batch = sale_order._get_current_batch()
if not batch:
batch = sale_order.env["sale.order.batch"].create({})
@@ -50,6 +50,18 @@ class SaleOrder(models.Model):
"res_id": self.batch_id.id,
}
+ def action_quotation_send(self):
+ invalid_orders = []
+ if not self.env.context.get("bypass_batch", False):
+ for order in self:
+ if order.batch_id:
+ invalid_orders.append(order.name)
+ if invalid_orders:
+ raise UserError(
+ _(f"Sale Order belongs to a Batch: {', '.join(invalid_orders)}")
+ )
+ return super().action_quotation_send()
+
def action_confirm(self):
invalid_orders = []
if not self.env.context.get("bypass_batch", False):
diff --git a/sale_order_batch/models/sale_order_batch.py b/sale_order_batch/models/sale_order_batch.py
index 0f44883..713c517 100644
--- a/sale_order_batch/models/sale_order_batch.py
+++ b/sale_order_batch/models/sale_order_batch.py
@@ -172,8 +172,8 @@ class SaleOrderBatch(models.Model):
def action_in_progress(self):
for batch in self:
batch.sale_order_line_ids._validate_analytic_distribution()
- orders = batch.sale_order_ids
- orders.update({"state": "sent"})
+ orders = batch.with_context(bypass_batch=True).sale_order_ids
+ orders.action_quotation_sent()
batch.update({"state": "in_progress"})
return True
diff --git a/sale_order_batch/views/sale_order_views.xml b/sale_order_batch/views/sale_order_views.xml
index b2cfb34..0fc0a7d 100644
--- a/sale_order_batch/views/sale_order_views.xml
+++ b/sale_order_batch/views/sale_order_views.xml
@@ -30,6 +30,22 @@
+ {'invisible': [('batch_id', '!=', False)]}
+
+
+ {'invisible': [('batch_id', '!=', False)]}
+
+