|
92 | 92 | /> |
93 | 93 | </page> |
94 | 94 | <page string="Help"> |
95 | | - <group> |
96 | | - <div> |
97 | | - <h3>Help for Message Valude Code</h3> |
98 | | - <p |
99 | | - >Available evaluation context variables are as follows:</p> |
100 | | - <ul> |
101 | | - <li><code |
102 | | - >env</code>: Odoo environment for ORM access.</li> |
103 | | - <li><code>user</code>: Current user (<code |
104 | | - >env.user</code>).</li> |
105 | | - <li><code |
106 | | - >ctx</code>: Copy of the current context (<code |
107 | | - >dict(env.context)</code>).</li> |
108 | | - <li><code |
109 | | - >record</code>: Current record (the form's record).</li> |
110 | | - <li><code |
111 | | - >draft</code>: The persisted field values of the ORM record (before applying the current |
112 | | - form's unsaved changes) + the current unsaved changes on trigger fields. |
113 | | - Should be used instead of <code |
114 | | - >record</code> when your rule is triggered dynamically by an |
115 | | - update to a trigger field. It doesn't include any values from complex fields |
116 | | - (x2many/reference, etc). |
117 | | - </li> |
118 | | - <li><code |
119 | | - >current_id</code>: Integer id of the record being edited, or <code |
120 | | - >False</code> if the form |
121 | | - is creating a new record. |
122 | | - </li> |
123 | | - <li><code |
124 | | - >model</code>: Shortcut to the current model (<code |
125 | | - >env[record._name]</code>).</li> |
126 | | - <li><code |
127 | | - >url_for(obj)</code>: Helper that returns a backend form URL for <code |
128 | | - >obj</code>.</li> |
129 | | - <li><code |
130 | | - >context_today(ts=None)</code>: User-timezone “today” (date) for reliable date comparisons.</li> |
131 | | - <li><code |
132 | | - >time, datetime</code>: Standard Python time/datetime modules.</li> |
133 | | - <li><code>dateutil</code>: <code |
134 | | - >{ "parser": dateutil.parser, "relativedelta": dateutil.relativedelta }</code></li> |
135 | | - <li><code>timezone</code>: <code |
136 | | - >pytz.timezone</code> for TZ handling.</li> |
137 | | - <li><code>float_compare</code>, <code |
138 | | - >float_is_zero</code>, <code |
139 | | - >float_round</code>: Odoo float utils for precision-safe comparisons/rounding.</li> |
140 | | - </ul> |
141 | | - <p>Example of Message Value Code (model: <code |
142 | | - >sale.order</code>)</p> |
143 | | - <code style="white-space: pre-wrap"> |
144 | | -domain = [("partner_id", "=", draft.partner_id.id)] |
| 95 | + <h3>Help for Message Valude Code</h3> |
| 96 | + <p |
| 97 | + >Available evaluation context variables are as follows:</p> |
| 98 | + <ul> |
| 99 | + <li><code |
| 100 | + >env</code>: Odoo environment for ORM access.</li> |
| 101 | + <li><code>user</code>: Current user (<code |
| 102 | + >env.user</code>).</li> |
| 103 | + <li><code>ctx</code>: Copy of the current context (<code |
| 104 | + >dict(env.context)</code>).</li> |
| 105 | + <li><code |
| 106 | + >record</code>: Current record (the form's record).</li> |
| 107 | + <li><code |
| 108 | + >draft</code>: The persisted field values of the ORM record (before applying the current |
| 109 | + form's unsaved changes) + the current unsaved changes on trigger fields. |
| 110 | + Should be used instead of <code |
| 111 | + >record</code> when your rule is triggered dynamically by an |
| 112 | + update to a trigger field. It doesn't include any values from complex fields |
| 113 | + (one2many/reference, etc). |
| 114 | + </li> |
| 115 | + <li><code |
| 116 | + >current_id</code>: Integer id of the record being edited, or <code |
| 117 | + >False</code> if the form |
| 118 | + is creating a new record. |
| 119 | + </li> |
| 120 | + <li><code |
| 121 | + >model</code>: Shortcut to the current model (<code |
| 122 | + >env[record._name]</code>).</li> |
| 123 | + <li><code |
| 124 | + >url_for(obj)</code>: Helper that returns a backend form URL for <code |
| 125 | + >obj</code>.</li> |
| 126 | + <li><code |
| 127 | + >context_today(ts=None)</code>: User-timezone “today” (date) for reliable date comparisons.</li> |
| 128 | + <li><code |
| 129 | + >time, datetime</code>: Standard Python time/datetime modules.</li> |
| 130 | + <li><code>dateutil</code>: <code |
| 131 | + >{ "parser": dateutil.parser, "relativedelta": dateutil.relativedelta }</code></li> |
| 132 | + <li><code>timezone</code>: <code |
| 133 | + >pytz.timezone</code> for TZ handling.</li> |
| 134 | + <li><code>float_compare</code>, <code |
| 135 | + >float_is_zero</code>, <code |
| 136 | + >float_round</code>: Odoo float utils for precision-safe comparisons/rounding.</li> |
| 137 | + </ul> |
| 138 | + <p>Example of Message Value Code (model: <code |
| 139 | + >sale.order</code>)</p> |
| 140 | + <pre |
| 141 | + style="white-space: pre-wrap" |
| 142 | + >domain = [("partner_id", "=", draft.partner_id.id)] |
145 | 143 | if record_id: |
146 | | - domain += [("id", "&lt;", record_id)] |
| 144 | + domain += [("id", "<", record_id)] |
147 | 145 | last = model.search(domain, order="date_order desc, id desc", limit=1) |
148 | 146 | if last: |
149 | | - html = "&lt;strong&gt;Previous order:&lt;/strong&gt; &lt;a href='%s'&gt;%s&lt;/a&gt;" % (url_for(last), last.name) |
150 | | - result = {"visible": True, "html": html} |
| 147 | + html = "<strong>Previous order:</strong> <a href='%s'>%s</a>" % (url_for(last), last.name) |
| 148 | + result = {"visible": True, "html": html} |
151 | 149 | else: |
152 | | - result = {"visible": False} |
153 | | -</code> |
154 | | - </div> |
155 | | - </group> |
| 150 | + result = {"visible": False} |
| 151 | +</pre> |
156 | 152 | </page> |
157 | 153 | </notebook> |
158 | 154 | </sheet> |
|
0 commit comments