From fd6bcd27eabae7d3e8e1356e9a2aa046e8d19486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 23 Sep 2021 10:12:01 +0200 Subject: [PATCH] Use Warning.format in documentation example issue10767 review375491003 --- doc/topics/user_errors_warnings.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/topics/user_errors_warnings.rst b/doc/topics/user_errors_warnings.rst index 72980cb56d..c1e9ba179c 100644 --- a/doc/topics/user_errors_warnings.rst +++ b/doc/topics/user_errors_warnings.rst @@ -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.")