Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 improve search_or_create #159

Draft
wants to merge 1 commit into
base: 13.0
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions base_api/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Usage
search_or_create
----------------

*search_or_create(self, vals, active\_test=True)*
*search_or_create(self, vals, active\_test=True, domain=None)*

*– Purpose*:
- To resolve “race conditions”, comparing to separated searching
Expand All @@ -36,15 +36,26 @@ search_or_create

 active_test = False` # to also search in *in-active* records

- `domain`-variable explicit search domain before creating
*– Notes*:
- *many2one* fields in `vals`:
- type of integer
- e.g.
- integer or dictionary
- example for integer
.. code-block::

vals = {
'company_id': 1
}
- dictionary has same arguments as for `search_or_create` itself
.. code-block::

vals = {
'company_id': {
'vals': {
'name': 'My Company'
}
}
}

- *x2many* fields in `vals`:
- ignored for searching
Expand Down Expand Up @@ -89,7 +100,7 @@ search_or_create

*– Algorithm*:

1. Creates *domain* out of `vals` for searching
1. If `domain` arg is not provided, create *domain* out of `vals` for searching

2. Searches for records satisfiy *domain* constraints (`is_new = False`)

Expand Down