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

7.0 search payment methods with company #52

Closed

Conversation

kenvac
Copy link

@kenvac kenvac commented Oct 15, 2014

Fix for issue #51

@@ -905,6 +905,7 @@ def store_id(self, record):
'non existing storeview')
storeview = self.session.browse('magento.storeview', storeview_id)
shop_id = storeview.store_id.openerp_id.id
self.session.context['shop'] = shop_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The context should not be mutated directly in the session, it should be changed with with self.session.change_context(...):. It should not be modifier in the Mapper since the Mapper should only take data in and return data out, and not use a side effect on the state of the Importer. The Importer has the responsibility to change the context for example before calling the creation or update of the record.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change that one. Thanks.

@guewen
Copy link
Member

guewen commented Oct 20, 2014

The multi-company is currently not well supported and this fix is aiming to a better support, so thanks for you proposal. However, this is not the approach I would take. Here is mine:

Each website or store view should be linked to a company, and each company should have a new field connector_user_id. This field is a relation to a user who is himself assigned to one company. Seems a bit strange but there is a reason: when a website / store view has a company and this company has a connector_user_id, the connector will be able to switch to this user, letting OpenERP apply record rules and properties according to this user. The domain should not be modified in the mapper because the record rule will automatically restrict on the allowed payment methods.

Here is an example of implementation: https://gist.github.com/guewen/3528fe4be6bf527ed9d9 and a thread discussing that: https://www.mail-archive.com/openerp-connector-community@lists.launchpad.net/msg00091.html

The big benefit of this approach is that we don't need to change every domain in all the mappings to ensure they filter on the company. This is also the only way to be sure that the property fields are set correctly and the internal OpenERP code (function fields, ...) use the correct company.

@kenvac
Copy link
Author

kenvac commented Oct 21, 2014

guewen, Thanks for spending your valuable time and putting comment here.
I got your point of setting up new users per company. But, how do I configure them to use with per storeview/store/website? It might be easy, sorry for being so naive.

@guewen
Copy link
Member

guewen commented Oct 22, 2014

When importing a sales order, it is linked to a shop which has a company_id field, so you will assign the right company to each shop.

In the Magento importer, it will give something like that:

@magento
class SaleOrderImport(MagentoImportSynchronizer):
    _model_name = ['magento.sale.order']

    def _import(self, binding_id):
        binder = self.get_binder_for_model('magento.storeview')
        storeview_id = binder.to_openerp(record['store_id'])
        assert storeview_id is not None, ('cannot import sale orders from '
            'non existing storeview')
        storeview = self.session.browse('magento.storeview', storeview_id)
        shop = storeview.store_id
        user = shop.company_id.connector_user_id
        if user:
            with self.session.change_user(user.id):
                super(SaleOrderImport, self)._import(binding_id)
        else:
             super(SaleOrderImport, self)._import(binding_id)

@mistotebe
Copy link

How does a new user per company play with Odoo pricing? Do you know if such users would be considered active and charged for under the support contract? If so, this might be an issue for some customers who have several companies but only a few users per company (and none of those user can be reused for magento sync).

@guewen
Copy link
Member

guewen commented Nov 26, 2014

@mistotebe only users who have logged in at least 1 time should be charged.

@pedrobaeza
Copy link
Member

Is this going to be continued?

@mistotebe
Copy link

Unlikely, there is no v7 multi-company with Magento integration that we need it for anymore.

@pedrobaeza pedrobaeza closed this Oct 5, 2016
jcoux pushed a commit to camptocamp/connector-magento that referenced this pull request May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants