mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
@@ -30,10 +30,14 @@ class ContractContract(models.Model):
|
||||
orders = self.contract_line_ids.mapped(
|
||||
'sale_order_line_id.order_id'
|
||||
)
|
||||
return {
|
||||
action = {
|
||||
"name": _("Sales Orders"),
|
||||
"view_mode": "tree,form",
|
||||
"res_model": "sale.order",
|
||||
"type": "ir.actions.act_window",
|
||||
"domain": [("id", "in", orders.ids)],
|
||||
}
|
||||
if len(orders) == 1:
|
||||
# If there is only one order, open it directly
|
||||
action.update({'view_mode': "form", "res_id": orders.id})
|
||||
return action
|
||||
|
||||
@@ -117,4 +117,15 @@ class SaleOrder(models.Model):
|
||||
.mapped('contract_id')
|
||||
)
|
||||
action["domain"] = [("id", "in", contracts.ids)]
|
||||
if len(contracts) == 1:
|
||||
# If there is only one contract, open it directly
|
||||
action.update(
|
||||
{
|
||||
"res_id": contracts.id,
|
||||
"view_mode": "form",
|
||||
"views": filter(
|
||||
lambda view: view[1] == 'form', action['views']
|
||||
),
|
||||
}
|
||||
)
|
||||
return action
|
||||
|
||||
Reference in New Issue
Block a user