Use Warning.format in documentation example

issue10767
review375491003
This commit is contained in:
Cédric Krier
2021-09-23 10:12:01 +02:00
parent b5af64f6d3
commit fd6bcd27ea
+3 -2
View File
@@ -42,7 +42,8 @@ A warning displays a confirmation message with optionally a description to the
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 @@ Example:
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.")