From e7d7aae2e9f00b4163b08e256e1caaf220645f0f Mon Sep 17 00:00:00 2001 From: mariadforgeflow Date: Mon, 23 May 2022 17:32:52 +0200 Subject: [PATCH] [FIX] contract: add default_move_type in context --- contract/models/contract.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/contract/models/contract.py b/contract/models/contract.py index 364013540..1e95a7b40 100644 --- a/contract/models/contract.py +++ b/contract/models/contract.py @@ -277,12 +277,20 @@ class ContractContract(models.Model): self.ensure_one() tree_view = self.env.ref("account.view_invoice_tree", raise_if_not_found=False) form_view = self.env.ref("account.view_move_form", raise_if_not_found=False) + ctx = dict(self.env.context) + if ctx.get("default_contract_type"): + ctx["default_move_type"] = ( + "out_invoice" + if ctx.get("default_contract_type") == "sale" + else "in_invoice" + ) action = { "type": "ir.actions.act_window", "name": "Invoices", "res_model": "account.move", "view_mode": "tree,kanban,form,calendar,pivot,graph,activity", "domain": [("id", "in", self._get_related_invoices().ids)], + "context": ctx, } if tree_view and form_view: action["views"] = [(tree_view.id, "tree"), (form_view.id, "form")]