Merge PR #479 into 12.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot
2020-03-08 20:48:00 +00:00
2 changed files with 16 additions and 1 deletions

View File

@@ -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

View File

@@ -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