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.
This commit is contained in:
Leonardo Donelli 2017-02-01 19:26:46 +01:00
parent 9b7799d749
commit d67f4b616b
2 changed files with 5 additions and 2 deletions

View File

@ -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)]')

View File

@ -11,7 +11,9 @@
<sheet>
<group>
<field name="name"/>
<field name="document_type_id"/>
<!-- Needed for the automatic domain on document_type_id -->
<field name="res_model" invisible="True"/>
<field name="document_type_id" options="{'no_create': True}"/>
<field name="description"/>
</group>
</sheet>