@@ -6,7 +6,7 @@ The `Upgrade Util package <https://github.com/odoo/upgrade-util/>`_ is a library
66helper functions to facilitate the writing of upgrade scripts. This package, used by Odoo for the
77upgrade scripts of standard modules, provides reliability and helps speed up the upgrade process:
88
9- - The helper functions make sure the data is consitent in the database.
9+ - The helper functions help make sure the data is consistent in the database.
1010- It takes care of indirect references of the updated records.
1111- Allows calling functions and avoid writing code, saving time and reducing development risks.
1212- Helpers allow to focus on what is important for the upgrade and not think of details.
@@ -37,7 +37,7 @@ Using the Util package
3737
3838Once installed, the following packages are available for the upgrade scripts:
3939
40- - :mod: `odoo.upgrade.util `: the helper themself .
40+ - :mod: `odoo.upgrade.util `: the helper itself .
4141- :mod: `odoo.upgrade.testing `: base TestCase classes.
4242
4343To use it in upgrade scripts, simply import it:
@@ -62,47 +62,45 @@ helper functions.
6262
6363.. note ::
6464
65- All util functions receive :attr: `cr ` as a parameter. This refers to the database cursor. Use the
66- one received as a parameter in the :doc: `upgrade_scripts `.
65+ All util functions receive :attr: `cr ` as a parameter. This refers to the database cursor. Pass
66+ the one received as a parameter in the :doc: `upgrade_scripts `.
6767
6868Fields
6969------
7070
7171.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/fields.py#L91>`_
72- .. method :: remove_field(cr, model, fieldname[ , cascade=False][ , drop_column=True][ , skip_inherit=()] )
72+ .. method :: remove_field(cr, model, fieldname, cascade=False, drop_column=True, skip_inherit=())
7373
74- Remove a field and its references from the database
74+ Remove a field and its references from the database.
7575
7676 :param str model: model name of the field to remove
7777 :param str fieldname: name of the field to remove
78- :param bool cascade: if ``True ``, removes the field's column and inheritance in ``CASCADE ``
79- (default: ``False ``)
80- :param bool drop_column: if ``True ``, drops the field's column (default: ``True ``)
78+ :param bool cascade: whether the field's column and inheritance are removed in ``CASCADE ``
79+ :param bool drop_column: whether the field's column is dropped
8180 :param list(str) or str skip_inherit: list of models whose field's inheritance is skipped.
8281 Use ``"*" `` to skip all inheritances
8382
8483.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/fields.py#L362>`_
85- .. method :: rename_field(cr, model, old, new[ , update_references=True][ , domain_adapter=None][ , skip_inherit=()] )
84+ .. method :: rename_field(cr, model, old, new, update_references=True, domain_adapter=None, skip_inherit=())
8685
87- Rename a field and its references from ``old `` to ``new ``
86+ Rename a field and its references from ``old `` to ``new ``.
8887
8988 :param str model: model name of the field to rename
9089 :param str old: current name od the field to rename
9190 :param str new: new name od the field to rename
92- :param bool update_references: if `` True ``, Replace all references of field ``old `` to ``new ``
91+ :param bool update_references: whether all references of field ``old `` to ``new `` are replaced
9392 in: ``ir_filters ``, ``ir_exports_line ``, ``ir_act_server ``, ``mail_alias ``,
9493 ``ir_ui_view_custom (dashboard) ``, ``domains (using "domain_adapter") ``, ``related fields ``
95- (default: ``True ``)
9694 :param function domain_adapter: function that takes three arguments and returns a domain that
9795 substitutes the original leaf: ``(leaf: Tuple[str,str,Any], in_or: bool, negated: bool) `` ->
9896 ``List[Union[str,Tuple[str,str,Any]]] ``
9997 :param list(str) or str skip_inherit: list of models whose field's inheritance is skipped.
10098 Use ``"*" `` to skip all inheritances
10199
102100.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/fields.py#L337>`_
103- .. method :: move_field_to_module(cr, model, fieldname, old_module, new_module[ , skip_inherit=()] )
101+ .. method :: move_field_to_module(cr, model, fieldname, old_module, new_module, skip_inherit=())
104102
105- Move a field's reference in ``ir_model_data `` table from ``old_module `` to ``new_module ``
103+ Move a field's reference in ``ir_model_data `` table from ``old_module `` to ``new_module ``.
106104
107105 :param str model: model name of the field to move
108106 :param str fieldname: name of the field to move
@@ -115,26 +113,26 @@ Models
115113------
116114
117115.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/models.py#L53>`_
118- .. method :: remove_model(cr, model[ , drop_table=True][ , ignore_m2m=()] )
116+ .. method :: remove_model(cr, model, drop_table=True, ignore_m2m=())
119117
120- Remove a model and its references from the database
118+ Remove a model and its references from the database.
121119
122120 :param str model: name of the model to remove
123- :param bool drop_table: if `` True ``, drops the model's table (default: `` True ``)
121+ :param bool drop_table: whether the model's table is dropped
124122 :param list(str) or str ignore_m2m: list of m2m tables ignored to remove. Use ``"*" `` to ignore
125123 all m2m tables
126124
127125.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/models.py#L203>`_
128- .. method :: rename_model(cr, old, new[ , rename_table=True] )
126+ .. method :: rename_model(cr, old, new, rename_table=True)
129127
130- Rename a model and its references from ``old `` to ``new ``
128+ Rename a model and its references from ``old `` to ``new ``.
131129
132130 :param str old: current name of the model to rename
133131 :param str new: new name of the model to rename
134- :param bool rename_table: if `` True ``, renames the model's table (default: `` True ``)
132+ :param bool rename_table: whether the model's table is renamed
135133
136134.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/models.py#L323>`_
137- .. method :: merge_model(cr, source, target[ , drop_table=True][ , fields_mapping=None][ , ignore_m2m=()] )
135+ .. method :: merge_model(cr, source, target, drop_table=True, fields_mapping=None, ignore_m2m=())
138136
139137 Merge the references from ``source `` model into ``target `` model and removes ``source `` model and
140138 its references. By default, only the fields with the same name in both models are mapped.
@@ -144,7 +142,7 @@ Models
144142
145143 :param str source: name of the source model of the merge
146144 :param str target: name of the destination model of the merge
147- :param bool drop_table: if `` True ``, drops the source model's table (default: `` True ``)
145+ :param bool drop_table: whether the source model's table is dropped
148146 :param dict fields_mapping: Dictionary ``{"source_model_field_1": "target_model_field_1", ...} ``
149147 mapping fields with different names on both models
150148 :param list(str) or str ignore_m2m: list of m2m tables ignored to remove from source model.
@@ -155,92 +153,91 @@ Modules
155153.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/modules.py#L218>`_
156154 .. method :: remove_module(cr, module)
157155
158- Uninstall and remove a module and its references from the database
156+ Uninstall and remove a module and its references from the database.
159157
160158 :param str module: name of the module to remove
161159
162160.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/modules.py#L263>`_
163161 .. method :: rename_module(cr, old, new)
164162
165- Rename a module and its references from ``old `` to ``new ``
163+ Rename a module and its references from ``old `` to ``new ``.
166164
167165 :param str old: current name of the module to rename
168166 :param str new: new name of the module to rename
169167
170168.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/modules.py#L323>`_
171169 .. method :: merge_module(cr, old, into, update_dependers=True)
172170
173- Move all references of module ``old `` into module ``into ``
171+ Move all references of module ``old `` into module ``into ``.
174172
175173 :param str old: name of the source module of the merge
176174 :param str into: ame of the destination module of the merge
177- :param bool update_dependers: if `` True ``, updates the dependencies of modules that depends on
178- `` old `` (default: `` True ``)
175+ :param bool update_dependers: whether the dependencies of modules that depends on `` old `` are
176+ updated
179177
180178ORM
181179---
182180
183181.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/orm.py#L43>`_
184182 .. method :: env(cr)
185183
186- Create a new environment from the cursor
184+ Create a new environment from the cursor.
187185
188186 .. warning ::
189187 This function does NOT empty the cache maintained on the cursor for superuser with an empty
190- environment. A call to invalidate_cache will most probably be necessary every time you
188+ environment. A call to ` invalidate_cache ` will most probably be necessary every time you
191189 directly modify something in database.
192190
193191 :return: The new environment
194192 :rtype: :class: `~odoo.api.Environment `
195193
196194.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/orm.py#L218>`_
197- .. method :: recompute_fields(cr, model, fields[ , ids=None][ , logger=_logger][ , chunk_size=256][ , strategy="auto"] )
195+ .. method :: recompute_fields(cr, model, fields, ids=None, logger=_logger, chunk_size=256, strategy="auto")
198196
199- Recompute field values
197+ Recompute field values.
200198
201199 :param str model: model name of the field(s) to recompute
202200 :param list(str) fields: list of field names to recompute
203201 :param list(int) ids: list of record IDs to recompute
204202 :param logger: Logger used to print the progress of the function
205- :type: logger: :class: `logging.Logger `
203+ :type logger: :class: `logging.Logger `
206204 :param int chunk_size: size of the chunk used to split the records for better processing
207- (default: ``256 ``)
208- :param str strategy: strategy used to process the recomputation (default: ``auto ``):
205+ :param str strategy: strategy used to process the recomputation:
209206
210207 - ``flush ``: Flush the recomputation when it's finished
211208 - ``commit ``: Commit the recomputation when it's finished
212209 - ``auto ``: The function chooses the best alternative for the recomputation based on the
213- number of records to recompute and the fields traceability.
210+ number of records to recompute and the fields traceability
214211
215212Records
216213-------
217214
218215.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/records.py#L612>`_
219216 .. method :: ref(cr, xmlid)
220217
221- Return the id corresponding to the given :term: `xml_id <external identifier> `
218+ Return the id corresponding to the given :term: `xml_id <external identifier> `.
222219
223220 :param str xml_id: Record xml_id, under the format ``<module.id> ``
224- :return: Found record id or None
225- :rtype: int
221+ :return: Found record id, if any
222+ :rtype: int or ` None `
226223
227224.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/records.py#L281>`_
228225 .. method :: remove_record(cr, name)
229226
230- Remove a record and its references corresponding to the given :term: `xml_id <external identifier> `
227+ Remove a record and its references corresponding to the given
228+ :term: `xml_id <external identifier> `.
231229
232230 :param str name: record xml_id, under the format ``<module.id> ``
233231
234232.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/records.py#L548>`_
235- .. method :: rename_xmlid(cr, old, new[ , noupdate=None][ , on_collision="fail"] )
233+ .. method :: rename_xmlid(cr, old, new, noupdate=None, on_collision="fail")
236234
237- Rename the :term: `external Identifier ` of a record
235+ Rename the :term: `external Identifier ` of a record.
238236
239237 :param str old: current xml_id of the record, under the format ``<module.id> ``
240238 :param str new: new xml_id of the record, under the format ``<module.id> ``
241- :param bool noupdate: value to set on the ir_model_data record ``noupdate `` field (default:
242- ``None ``)
243- :param str on_collision: action to take if the new xml_id already exists (default: ``fail ``)
239+ :param bool noupdate: value to set on the ir_model_data record ``noupdate `` field
240+ :param str on_collision: action to take if the new xml_id already exists
244241
245242 - ``fail ``: raise ``MigrationError `` and prevent renaming
246243 - ``merge ``: renames the external Identifier and removes the old one
@@ -267,17 +264,15 @@ Records
267264 :rtype: str
268265
269266.. `[source] <https://github.com/odoo/upgrade-util/blob/master/src/util/records.py#L720>`_
270- .. method :: update_record_from_xml(cr, xmlid[ , reset_write_metadata=True][ , force_create=True][ , from_module=None][ , reset_translations=()] )
267+ .. method :: update_record_from_xml(cr, xmlid, reset_write_metadata=True, force_create=True, from_module=None, reset_translations=())
271268
272269 Update a record based on its definition in the :doc: `/developer/reference/backend/data `.
273270
274271 Useful to update ``noupdate `` records, in order to reset them for the upgraded version.
275272
276273 :param str xmlid: record xml_id, under the format ``<module.id> ``
277- :param bool reset_write_metadata: if ``True ``, the metadata before the record update is kept
278- (default: ``True ``)
279- :param bool force_create: if ``True ``, creates the record if it does not exist. (default:
280- ``True ``)
274+ :param bool reset_write_metadata: whether the metadata before the record update is kept
275+ :param bool force_create: whether the record is created if it does not exist
281276 :param str from_module: name of the module from which to update the record. Useful when the
282277 record is rewritten in another module.
283- :param set of str reset_translations: set of field names whose translations get reset.
278+ :param set of str reset_translations: set of field names whose translations get reset
0 commit comments