From d67f4b616b837102d63a715131bf93276ac62a26 Mon Sep 17 00:00:00 2001 From: Leonardo Donelli Date: Wed, 1 Feb 2017 19:26:46 +0100 Subject: [PATCH] Filter possible document types on the model When choosing a document type for an attachment, only document types of the related record model are proposed. --- document_type/models/document_type.py | 3 ++- document_type/views/attachment.xml | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/document_type/models/document_type.py b/document_type/models/document_type.py index 114b11a6..11d8ae95 100644 --- a/document_type/models/document_type.py +++ b/document_type/models/document_type.py @@ -15,4 +15,5 @@ class IrAttachment(models.Model): _inherit = 'ir.attachment' document_type_id = fields.Many2one( - 'document.type', string='Document Type') + 'document.type', string='Document Type', + domain='[("ir_model_id.model", "=", res_model)]') diff --git a/document_type/views/attachment.xml b/document_type/views/attachment.xml index 810b08d3..d9dbaeeb 100644 --- a/document_type/views/attachment.xml +++ b/document_type/views/attachment.xml @@ -11,7 +11,9 @@ - + + +