mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-28 19:36:30 -06:00
Add documents count smart buttons for document type
This commit is contained in:
parent
d67f4b616b
commit
2bd6f94dab
@ -9,6 +9,11 @@ class DocumentType(models.Model):
|
|||||||
ir_model_id = fields.Many2one('ir.model', string='Object')
|
ir_model_id = fields.Many2one('ir.model', string='Object')
|
||||||
document_ids = fields.One2many(
|
document_ids = fields.One2many(
|
||||||
'ir.attachment', 'document_type_id', string='Documents')
|
'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):
|
class IrAttachment(models.Model):
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form>
|
<form>
|
||||||
<sheet>
|
<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>
|
<group>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="ir_model_id"/>
|
<field name="ir_model_id"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user