changeset 9044da30abd2 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=9044da30abd2
description:
        Use Warning.format in documentation example

        issue10767
        review375491003
diffstat:

 doc/topics/user_errors_warnings.rst |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (22 lines):

diff -r 2ed802287fcb -r 9044da30abd2 doc/topics/user_errors_warnings.rst
--- a/doc/topics/user_errors_warnings.rst       Thu Sep 23 10:10:51 2021 +0200
+++ b/doc/topics/user_errors_warnings.rst       Thu Sep 23 10:12:01 2021 +0200
@@ -42,7 +42,8 @@
 user. The user can decide to continue so the request is processed again without
 stopping at the warning. Otherwise the user can cancel its request.
 The warning instance is identified by a name which allows to skip it the next
-time it is checked, that's why they often contain data like the id of a record.
+time it is checked, that's why they often build using the ``format`` method
+which uses record instances to generate a unique name based on ids.
 
 Example:
 
@@ -60,7 +61,7 @@
 
         def process(self):
             Warning = Pool().get('res.user.warning')
-            warning_name = 'mywarning,%s' % self
+            warning_name = Warning.format('mywarning', [self])
             if Warning.check(warning_name):
                 raise UserWarning(warning_name, "Process cannot be canceled.")
 

Reply via email to