[16.0] sale_order_batch: fix add followers bug
This commit is contained in:
parent
89bb11becc
commit
12736d9972
3 changed files with 31 additions and 3 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,22 @@
|
|||
</button>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//button[@name='action_quotation_send'][@states='draft']"
|
||||
position="attributes"
|
||||
>
|
||||
<attribute
|
||||
name="attrs"
|
||||
>{'invisible': [('batch_id', '!=', False)]}</attribute>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//button[@name='action_quotation_send'][@states='sent,sale']"
|
||||
position="attributes"
|
||||
>
|
||||
<attribute
|
||||
name="attrs"
|
||||
>{'invisible': [('batch_id', '!=', False)]}</attribute>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//button[@name='action_confirm']"
|
||||
position="attributes"
|
||||
>
|
||||
|
|
|
|||
Loading…
Reference in a new issue