{"action":"created","issue":{"url":"https://api.github.com/repos/OCA/connector/issues/47","labels_url":"https://api.github.com/repos/OCA/connector/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/OCA/connector/issues/47/comments","events_url":"https://api.github.com/repos/OCA/connector/issues/47/events","html_url":"https://github.com/OCA/connector/pull/47","id":58205257,"number":47,"title":"New API in connector, bump to 3.0.0","user":{"login":"guewen","id":417223,"avatar_url":"https://avatars.githubusercontent.com/u/417223?v=3","gravatar_id":"","url":"https://api.github.com/users/guewen","html_url":"https://github.com/guewen","followers_url":"https://api.github.com/users/guewen/followers","following_url":"https://api.github.com/users/guewen/following{/other_user}","gists_url":"https://api.github.com/users/guewen/gists{/gist_id}","starred_url":"https://api.github.com/users/guewen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guewen/subscriptions","organizations_url":"https://api.github.com/users/guewen/orgs","repos_url":"https://api.github.com/users/guewen/repos","events_url":"https://api.github.com/users/guewen/events{/privacy}","received_events_url":"https://api.github.com/users/guewen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/OCA/connector/labels/needs%20review","name":"needs review","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-19T13:02:44Z","updated_at":"2015-03-20T08:34:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/OCA/connector/pulls/47","html_url":"https://github.com/OCA/connector/pull/47","diff_url":"https://github.com/OCA/connector/pull/47.diff","patch_url":"https://github.com/OCA/connector/pull/47.patch"},"body":"\r\n\r\nThe changes done here will break the API compatibility.\r\nHowever, they are necessary to keep up with the changes in Odoo.\r\n\r\nThe API in the connector still uses the `cr, uid, ids, context` api, even if\r\nhidden in `connector.Session`. Not using new recordsets is restricting.\r\n\r\nExample:\r\nIf I implements a new onchange on `sale.order`:\r\n\r\n```python\r\nclass SaleOrder(models.Model):\r\n    @api.onchange('workflow_process_id'):\r\n    def onchange_workflow_process_id(self):\r\n        self.payment_method_id = self.workflow_process_id.payment_method_id\r\n```\r\n\r\nThen I won't be able to call from within a `ConnectorUnit` directly.\r\nLocally I could do:\r\n```python\r\nimport openerp\r\n[...]\r\n\r\n  env = openerp.api.Environment(self.session.cr,\r\n                                self.session.uid,\r\n                                self.session.context)\r\n  sale = env['sale.order'].new(values)\r\n  sale.onchange_workflow_process_id()\r\n```\r\nBut it would be far better to include the new API in the root classes.\r\n\r\n# Changes:\r\n\r\n* Add ``openerp.api.Environment`` in ``Session``\r\n  It is accessible in ``self.env`` in ``Session`` and all\r\n  ``ConnectorUnit`` instances.\r\n  Also in ``ConnectorUnit``, ``model`` returns the current (new api!) model:\r\n\r\n  ```python\r\n      # On the current model\r\n      self.model.search([])\r\n      self.model.browse(ids)\r\n      # on another model\r\n      self.env['res.users'].search([])\r\n      self.env['res.users'].browse(ids)\r\n  ```\r\n\r\n* Deprecate the CRUD methods in ``Session``\r\n\r\n  ```python\r\n      # NO\r\n      self.session.search('res.partner', [])\r\n      self.session.browse('res.partner', ids)\r\n\r\n      # YES\r\n      self.env['res.partner'].search([])\r\n      self.env['res.partner'].browse(ids)\r\n  ```\r\n\r\n* ``Environment.set_lang()`` is removed. It was modifying the context\r\n  in place which is not possible with the new frozendict context. It\r\n  should be done with:\r\n\r\n  ```python\r\n\r\n      with self.session.change_context(lang=lang_code):\r\n          ...\r\n  ```\r\n\r\n* Add an argument on the Binders methods to return a browse record\r\n\r\n  ```python\r\n\r\n      binder.to_openerp(magento_id, browse=True)\r\n   ```\r\n\r\n* Shorten ``ConnectorUnit.get_binder_for_model`` to\r\n  ``ConnectorUnit.binder_for``\r\n* Shorten ``ConnectorUnit.get_connector_unit_for_model`` to\r\n  ``ConnectorUnit.unit_for``\r\n* Renamed ``Environment`` to ``ConnectorEnvironment`` to avoid\r\n  confusion with ``openerp.api.Environment``\r\n* Renamed the class attribute ``ConnectorUnit.model_name`` to\r\n  ``ConnectorUnit.for_model_name``.\r\n* Added ``_base_binder``, ``_base_mapper``, ``_base_backend_adapter`` in\r\n  the synchronizers (Importer, Exporter) so it is no longer required to\r\n  override the ``binder``, ``mapper``, ``backend_adapter`` property\r\n  methods\r\n* ``Session.change_context()`` now supports the same\r\n  argument/keyword arguments semantics than\r\n  ``openerp.model.BaseModel.with_context()``.\r\n* Renamed ``ExportSynchronizer`` to ``Exporter``\r\n* Renamed ``ImportSynchronizer`` to ``Importer``\r\n* Renamed ``DeleteSynchronizer`` to ``Deleter``\r\n* ``Session.commit`` do not commit when tests are running\r\n* Cleaned the methods that have been deprecated in version 2.x\r\n"},"comment":{"url":"https://api.github.com/repos/OCA/connector/issues/comments/83956651","html_url":"https://github.com/OCA/connector/pull/47#issuecomment-83956651","issue_url":"https://api.github.com/repos/OCA/connector/issues/47","id":83956651,"user":{"login":"guewen","id":417223,"avatar_url":"https://avatars.githubusercontent.com/u/417223?v=3","gravatar_id":"","url":"https://api.github.com/users/guewen","html_url":"https://github.com/guewen","followers_url":"https://api.github.com/users/guewen/followers","following_url":"https://api.github.com/users/guewen/following{/other_user}","gists_url":"https://api.github.com/users/guewen/gists{/gist_id}","starred_url":"https://api.github.com/users/guewen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guewen/subscriptions","organizations_url":"https://api.github.com/users/guewen/orgs","repos_url":"https://api.github.com/users/guewen/repos","events_url":"https://api.github.com/users/guewen/events{/privacy}","received_events_url":"https://api.github.com/users/guewen/received_events","type":"User","site_admin":false},"created_at":"2015-03-20T08:34:13Z","updated_at":"2015-03-20T08:34:13Z","body":"Branch's ready, I need reviews"}}