-
Notifications
You must be signed in to change notification settings - Fork 23.1k
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
[FW][FIX] stock: ensure name exists creating location #165941
Closed
fw-bot
wants to merge
1
commit into
odoo:saas-16.4
from
odoo-dev:saas-16.4-15.0-opw-3796010-import-repair-orders-etvi-Sk7w-fw
Closed
[FW][FIX] stock: ensure name exists creating location #165941
fw-bot
wants to merge
1
commit into
odoo:saas-16.4
from
odoo-dev:saas-16.4-15.0-opw-3796010-import-repair-orders-etvi-Sk7w-fw
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR targets saas-16.4 and is part of the forward-port chain. Further PRs will be created up to master. More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port |
@ethanrobv @Whenrow ci/runbot failed on this forward-port PR |
**Current behavior:** In some instances we will try to create a `stock.location` record from a `complete_name` field value (one such case is creating from import). When this happens, the creation will fail due to the not-null constraint on the `name` field in the table and display a SQL error in logs. **Expected behavior:** A `stock.location` record can be created via name. **Steps to reproduce:** 1. Create an .xlsx document representing a Repair Order to be imported, such that the `Location` cell value does not already exist in the database 2. Install the test-import-export module, go into the Repair app and from the favorites action button select import data 3. Upload the .xlsx file, press 'Test Import', select the 'Create New' option for offending data points 4. Observe that the new location can not be created, and in the console logs there is the output of the bad SQL query **Cause of the issue:** The `_rec_name` field for `stock.location` is `complete_name`, however it is not required while the `name` field is. When the INSERT query is constructed it will not include a name:val mapping and thus will fail due to the not-null constraint on the table for this column. **Fix:** Override name_create() in `stock.location` to create the record with `name` instead of `_rec_name`. opw-3796010 X-original-commit: eb69eee
ethanrobv
force-pushed
the
saas-16.4-15.0-opw-3796010-import-repair-orders-etvi-Sk7w-fw
branch
from
May 21, 2024 09:25
183f9ff
to
7d47f07
Compare
@ethanrobv @Whenrow this PR was modified / updated and has become a normal PR. It should be merged the normal way (via @robodoo) |
@robodoo r+ |
robodoo
pushed a commit
that referenced
this pull request
May 21, 2024
**Current behavior:** In some instances we will try to create a `stock.location` record from a `complete_name` field value (one such case is creating from import). When this happens, the creation will fail due to the not-null constraint on the `name` field in the table and display a SQL error in logs. **Expected behavior:** A `stock.location` record can be created via name. **Steps to reproduce:** 1. Create an .xlsx document representing a Repair Order to be imported, such that the `Location` cell value does not already exist in the database 2. Install the test-import-export module, go into the Repair app and from the favorites action button select import data 3. Upload the .xlsx file, press 'Test Import', select the 'Create New' option for offending data points 4. Observe that the new location can not be created, and in the console logs there is the output of the bad SQL query **Cause of the issue:** The `_rec_name` field for `stock.location` is `complete_name`, however it is not required while the `name` field is. When the INSERT query is constructed it will not include a name:val mapping and thus will fail due to the not-null constraint on the table for this column. **Fix:** Override name_create() in `stock.location` to create the record with `name` instead of `_rec_name`. opw-3796010 closes #165941 X-original-commit: eb69eee Signed-off-by: William Henrotin (whe) <whe@odoo.com> Signed-off-by: Vincent Ethan <etvi@odoo.com>
fw-bot
deleted the
saas-16.4-15.0-opw-3796010-import-repair-orders-etvi-Sk7w-fw
branch
June 4, 2024 12:46
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current behavior:
In some instances we will try to create a
stock.location
record from a
complete_name
field value (one such case iscreating from import). When this happens, the creation will fail
due to the not-null constraint on the
name
field in the tableand display a SQL error in logs.
Expected behavior:
Use part of the complete_name as the name.
Steps to reproduce:
Create an .xlsx document representing a Repair Order to be
imported, such that the
Location
cell value does notalready exist in the database
Install the test-import-export module, go into the Repair app
and from the favorites action button select import data
Upload the .xlsx file, press 'Test Import', select the
'Create New' option for offending data points
Observe that the new Location can not be created, and in the
console logs there is the output of the bad SQL query
Cause of the issue:
The
_rec_name
field forstock.location
iscomplete_name
,however the
name
field as also a required field. When wecreate the records in this flow,
_rec_name
is used to inferwhich fields need to be included in the query. So
name
isnever added to the INSERT query and we end up violating the
not-null constraint on this column of the table (bad query).
Fix:
If there is no
name
in the create vals dict for the locationrecord, use the end segment of
complete_name
.opw-3796010
Forward-Port-Of: #165447
Forward-Port-Of: #163298