Improve note button

* Add resources method to ModelStorage
* Support badge on icon
* Display unread and total of notes
* Add two extra colors for icon

issue8122
review70561002
This commit is contained in:
Cédric Krier
2019-03-22 12:16:36 +01:00
parent 07d79c7861
commit 2752490423
3 changed files with 25 additions and 0 deletions
+1
View File
@@ -1,3 +1,4 @@
* Add resources method to ModelStorage
* Validate selection format in Dict schema
* Allow to extend Field's string and help
* Add console
+5
View File
@@ -328,6 +328,11 @@ Dual methods:
Instance methods:
.. method:: ModelStorage.resources()
Return a dictionary with the number of attachments (`attachment_count`),
notes (`note_count`) and unread note (`note_unread`).
.. method:: ModelStorage.get_rec_name(name)
Getter for the :class:`trytond.model.fields.Function` field
+19
View File
@@ -114,6 +114,7 @@ class ModelStorage(Model):
'search': RPC(result=lambda r: list(map(int, r))),
'search_count': RPC(),
'search_read': RPC(),
'resources': RPC(instantiate=0, unique=False),
'export_data': RPC(instantiate=0, unique=False),
'import_data': RPC(readonly=False),
})
@@ -525,6 +526,24 @@ class ModelStorage(Model):
return domain
return process(domain)
def resources(self):
pool = Pool()
Attachment = pool.get('ir.attachment')
Note = pool.get('ir.note')
return {
'attachment_count': Attachment.search_count([
('resource', '=', str(self)),
]),
'note_count': Note.search_count([
('resource', '=', str(self)),
]),
'note_unread': Note.search_count([
('resource', '=', str(self)),
('unread', '=', True),
]),
}
def get_rec_name(self, name):
'''
Return the rec_name of the instance.