Add documents count smart buttons for document type

This commit is contained in:
Leonardo Donelli 2017-02-02 11:15:33 +01:00
parent d67f4b616b
commit 2bd6f94dab
2 changed files with 10 additions and 0 deletions

View File

@ -9,6 +9,11 @@ class DocumentType(models.Model):
ir_model_id = fields.Many2one('ir.model', string='Object')
document_ids = fields.One2many(
'ir.attachment', 'document_type_id', string='Documents')
documents_count = fields.Integer(compute='_compute_documents_count')
def _compute_documents_count(self):
for record in self:
record.documents_count = len(record.document_ids)
class IrAttachment(models.Model):

View File

@ -13,6 +13,11 @@
<field name="arch" type="xml">
<form>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="documents" class="oe_stat_button" icon="fa-book">
<field name="documents_count" string="Documents" widget="statinfo"/>
</button>
</div>
<group>
<field name="name"/>
<field name="ir_model_id"/>