-
-
Notifications
You must be signed in to change notification settings - Fork 440
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
New API in connector, bump to 3.0.0 #47
Conversation
""" Context Manager: temporarily change the user's session and | ||
restablish the normal user at closing, | ||
""" | ||
raise Exception('Deprecated: use sudo() on a recordset.') |
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.
Maybe just yield a new Environment, and restore the original at closing.
This is required by the new api.onchange methods. The change needs OCA/connector#47
'new-api model/recordset.') | ||
return self.session.pool.get(self.environment.model_name) | ||
|
||
def recordset(self, model=None): |
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.
The perfect name for this method would have been model
... but it is already used.
recordset
is a bit odd as it returns a model (but a model is also a new recordset in the new api), but I can't find a better name.
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.
What about records
?
users = self.records().search([]) # when the model of the ConnectorUnit is 'res.users'
users = self.records('res.users').search([]) # when the model is another thing
things = self.records().browse(ids)
things.unlink()
Coverage decreased (-0.22%) to 71.14% when pulling 0694a72440ca1ee07becabcef17dd5914d8480bd on guewen:8.0-connector-new-api into c89b66e on OCA:8.0. |
05b0b25
to
1c2412e
Compare
Start to deprecate the Session class which can be entirely replaced by openerp.Environment and recordsets. The first step is to include the env in Session, and in a later version we'll replace it entirely by openerp.Environment. Now, 'self.env' in any ConnectorUnit returns the new API 'env'.
223f2e7
to
adc07cb
Compare
Beware, it should now be used as a contextmanager
Allow to customize them without overriding the whole property mapper or backend_adapter.
Do not point directly to them from ConnectorUnit or Environment or it would not return the correct ones inside a Session.change_context() or Session.change_user()
And corrected a wrong __str__!
When a job has been canceled, it could no longer be read
Also documented a bit the construction of mappings in the metaclass
Branch's ready, I need reviews |
This is required by the new api.onchange methods. The change needs OCA/connector#47
This is required by the new api.onchange methods. The change needs OCA/connector#47
Well, I have to check it when I change Prestashop connector, but at first glance, it seems 👍 I think we can merge and then make possibles PRs to fix problems. |
I reviewed the code and tested it (as part of |
I proceed with the merge then and possible fixes will come as another PRs. Thanks to all that have contributed! |
New API in connector, bump to 3.0.0
@guewen, can you please include the same version log of this PR in any side of the web to have it as reference? |
@@ -1,6 +1,74 @@ | |||
Changelog | |||
--------- | |||
|
|||
3.0.0 (not released) |
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.
Date needs to be set
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.
I think you can make it via direct commit.
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.
done
What do you mean exactly by "in any side of the web"? |
Yeah, http://odoo-connector.com/project/changes.html#id2 is what I mean. Thanks. |
[MIG] Rename manifest file [MIG] Replace "openerp" ocurrences with "odoo" [MIG] Do not use RedmineConnectorSession anymore (issue #212) - extend ConnectorEnvironment to host the redmine_cache that was previously extended in RedmineConnectorSession - remove session parameter from connector.get_environment (the connector module takes the environment from the backend object now). the default language from the backend is not applied there, because the session object is not available anymore. - Simplify RedmineModelBinder reusing the generalizations from of Binder. This way the use of the session property is not needed. - Proxy the redmine_cache of RedmineImportSyncronizer to the one saved in the connector environment. The same happens for RedmineAdapter - Simplify RedmineImportSynchronizer to avoid the use of session - remove "session" parameter from: import_batch, import_record, mock_delay, get_environment, import_single_user_time_entries. It is not replaced with "env", because env parameter passing is also removed in the last version of odoo_connector. the environment is now taken from the backend_record... - that's why some methods pass now the backend object instead of the backend_id. The backend is used now to get the environment, not at the opossite. [MIG] replace `hr.analytic.timesheet` by `account.analytic.line` - since v9 the model 'hr.analytic.timesheet` has been replaced by `account.analytic.line`: https://github.com/OCA/OpenUpgrade/blob/9.0/addons/hr_timesheet/migrations/9.0.1.0/post-migration.py#L17 - note that in v9 we need also a mapper, in order to set:: is_timesheet = True during the import of the timesheet records [MIG] Use queue_job module from OCA/queue see: OCA/queue#1 [MIG] Renamed ImportSynchronizer to Importer - see: OCA/connector#47 [MIG] import exception module - the job exception types has been moved to the module: `queue_job`. - They are still loaded / proxied by the module `connector.exception`. - But somehow this requires that the module is correctly imported. - It is better to use always import. See: http://effbot.org/zone/import-confusion.htm - Import made similar to: OCA/connector#188 (comment) [MIG] slight changes to the Binder - Rename 'to_backend' to 'to_external' - Rename 'to_odoo' to 'to_internal' see: OCA/connector@fef7ee2 pep8 adjustments [MIG] rename ImportSynchronizers that left [MIG] fix hr_timesheet_sheet_form - the `buttons` element taked as reference by the previous version does not exist anymore - another position was selected so the result is the same fix pylint suggestions fix pyflakes errors
The changes done here will break the API compatibility.
However, they are necessary to keep up with the changes in Odoo.
The API in the connector still uses the
cr, uid, ids, context
api, even ifhidden in
connector.Session
. Not using new recordsets is restricting.Example:
If I implements a new onchange on
sale.order
:Then I won't be able to call from within a
ConnectorUnit
directly.Locally I could do:
But it would be far better to include the new API in the root classes.
Changes:
Add
openerp.api.Environment
inSession
It is accessible in
self.env
inSession
and allConnectorUnit
instances.Also in
ConnectorUnit
,model
returns the current (new api!) model:Deprecate the CRUD methods in
Session
Environment.set_lang()
is removed. It was modifying the contextin place which is not possible with the new frozendict context. It
should be done with:
Add an argument on the Binders methods to return a browse record
Shorten
ConnectorUnit.get_binder_for_model
toConnectorUnit.binder_for
Shorten
ConnectorUnit.get_connector_unit_for_model
toConnectorUnit.unit_for
Renamed
Environment
toConnectorEnvironment
to avoidconfusion with
openerp.api.Environment
Renamed the class attribute
ConnectorUnit.model_name
toConnectorUnit.for_model_name
.Added
_base_binder
,_base_mapper
,_base_backend_adapter
inthe synchronizers (Importer, Exporter) so it is no longer required to
override the
binder
,mapper
,backend_adapter
propertymethods
Session.change_context()
now supports the sameargument/keyword arguments semantics than
openerp.model.BaseModel.with_context()
.Renamed
ExportSynchronizer
toExporter
Renamed
ImportSynchronizer
toImporter
Renamed
DeleteSynchronizer
toDeleter
Session.commit
do not commit when tests are runningCleaned the methods that have been deprecated in version 2.x