-
-
Notifications
You must be signed in to change notification settings - Fork 153
[18.0][MIG] connector_importer_source_sftp: Migration to 18.0 #172
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
[18.0][MIG] connector_importer_source_sftp: Migration to 18.0 #172
Conversation
ae11221 to
4c59328
Compare
|
Hello @simahawk @sebalix @SilvioC2C can you pls help with any suggestions? |
So, the issue is definitely with the https://github.com/OCA/connector-interfaces/pull/172/files#r2476825551 |
| def _selection_source_ref_id(self): | ||
| selection = super()._selection_source_ref_id() | ||
| new_source = ("import.source.csv.sftp", "CSV SFTP") | ||
| if new_source not in selection: | ||
| selection.append(new_source) | ||
| return selection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not working as expected
| @@ -1,2 +1,2 @@ | |||
| from . import source_csv_sftp | |||
| from . import source_mixin | |||
| from . import source_csv_sftp | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivantodorovich this idea didn't help
|
|
||
| _name = "import.source.csv.sftp" | ||
| _inherit = [ | ||
| "import.source.csv", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try also inheriting from the mixin again here
| "import.source.csv", | |
| "import.source.csv", | |
| "import.source.consumer.mixin", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivantodorovich something really unexpected happening here. Seems still not working as expected. I wonder if we could adapt to use fields.Selection here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, simplify if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making source_model selection attribute as usual list of tuples and adding to the inherited class selection_add also doesn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simahawk @sebalix do you have any idea of the issue that _selection_source_ref_id override doesn't actually add new_source, simply not called.
connector_importer_source_sftp/models/source_mixin.py
@api.model
def _selection_source_ref_id(self):
selection = super()._selection_source_ref_id()
new_source = ("import.source.csv.sftp", "CSV SFTP")
if new_source not in selection:
selection.append(new_source)
return selection
982071a to
902dfd5
Compare
A file can be moved only if we have a destination path.
Instead of throwing an exception with an unclear message in the _get_line function
902dfd5 to
7ee25ea
Compare
f63f2f0 to
6db6bd8
Compare
|
Thanks for help @ivantodorovich 🙏 |
Traceback:
```
File ".../connector_importer_source_sftp/components/event_listeners.py", line 32, in _skip_move_file
source = importer.recordset.get_source()
File ".../connector_importer/models/sources/source_consumer_mixin.py", line 71, in get_source
return self.source_ref_id
File "/opt/odoo/odoo/fields.py", line 1303, in __get__
self.compute_value(recs)
File "/opt/odoo/odoo/fields.py", line 1485, in compute_value
records._compute_field_value(self)
File "/opt/odoo/odoo/models.py", line 5297, in _compute_field_value
fields.determine(field.compute, self)
File "/opt/odoo/odoo/fields.py", line 110, in determine
return needle(*args)
File ".../connector_importer/models/sources/source_consumer_mixin.py", line 43, in _compute_source_ref_id
item.source_ref_id = f"{item.source_model},{item.source_id}"
File "/opt/odoo/odoo/fields.py", line 1398, in __set__
self.write(protected_records, value)
File "/opt/odoo/odoo/fields.py", line 1205, in write
cache_value = self.convert_to_cache(value, records)
File "/opt/odoo/odoo/fields.py", line 3041, in convert_to_cache
raise ValueError("Wrong value for %s: %r" % (self, value))
ValueError: Wrong value for import.recordset.source_ref_id: 'import.source.csv.sftp,1'
```
For some reason I don't know, by the time the event listener skip_if condition is
evaluated, the `import.recordset` model does not have applied the override to
`_selection_source_ref_id` in the mixin, and so the Reference field fails with
this ValueError.
The workaround here makes `get_source` not actually use the Reference field, but
directly `source_model` and `source_id`, which of course do not attempt to
validate the value.
… tests For some reason, probably due to server_environment, if tests are ran during the module installation, like in the oca-ci, the storage backend_type is "filesystem", when it should be "sftp" according to the demo data. Did not investigate any further.
6db6bd8 to
91c1be3
Compare
|
@simahawk this one's ready too |
|
/ocabot merge nobump |
|
Hey, thanks for contributing! Proceeding to merge this for you. |
|
Congratulations, your PR was merged at 947f1ac. Thanks a lot for contributing to OCA. ❤️ |
No description provided.