changeset d1851fde50bc in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=d1851fde50bc
description:
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
diffstat:
CHANGELOG | 1 +
doc/ref/models/models.rst | 5 +++++
trytond/model/modelstorage.py | 19 +++++++++++++++++++
3 files changed, 25 insertions(+), 0 deletions(-)
diffs (59 lines):
diff -r 6c1469e8c837 -r d1851fde50bc CHANGELOG
--- a/CHANGELOG Fri Mar 22 11:46:52 2019 +0100
+++ b/CHANGELOG Fri Mar 22 12:16:36 2019 +0100
@@ -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
diff -r 6c1469e8c837 -r d1851fde50bc doc/ref/models/models.rst
--- a/doc/ref/models/models.rst Fri Mar 22 11:46:52 2019 +0100
+++ b/doc/ref/models/models.rst Fri Mar 22 12:16:36 2019 +0100
@@ -328,6 +328,11 @@
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
diff -r 6c1469e8c837 -r d1851fde50bc trytond/model/modelstorage.py
--- a/trytond/model/modelstorage.py Fri Mar 22 11:46:52 2019 +0100
+++ b/trytond/model/modelstorage.py Fri Mar 22 12:16:36 2019 +0100
@@ -114,6 +114,7 @@
'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 @@
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.