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

[Feature] Sales Order Salesperson #63

Open
dfrankland opened this issue Nov 11, 2014 · 2 comments
Open

[Feature] Sales Order Salesperson #63

dfrankland opened this issue Nov 11, 2014 · 2 comments

Comments

@dfrankland
Copy link

Salesperson in Sales Orders (sale.order.user_id) should be set as the customer's Salesperson (res.partner.user_id) on imported orders.

I know that other salespeople will not be able to see the orders then according to https://github.com/OCA/connector-magento/blob/7.0/magentoerpconnect/sale.py#L964-L968:

@mapping
    def user_id(self, record):
        """ Do not assign to a Salesperson otherwise sales orders are hidden
        for the salespersons (access rules)"""
        return {'user_id': False}

But, this is necessary for accounting and commission of salespeople, so maybe this should be configurable setting.

If anyone can also give a little direction as to how to proceed with this issue I can make a pull request.

@guewen
Copy link
Member

guewen commented Dec 9, 2014

Hi @dukedylan,

If the partner has a sales person, it could make sense to assign it to its new orders.
I don't want to add an option for every single detail though. So either we consider it is sufficiently generic (here I tend to think yes), either it should be done in a customization module.

You will have to modify the user_id mapping, the partner of the sale order is in self.options.partner_id, so you could modify it this way:

@mapping
def user_id(self, record):
    """ Assign the salesperson of the partner if any """
    if self.options.partner_id.user_id:
        return {'user_id': self.options.partner_id.user_id.id}
    return {'user_id': False}

@yostashiro
Copy link
Sponsor Member

Since self.options.partner_id is just an integer, the code should be like below:

    @mapping
    def user_id(self, record):
        """ Assign the salesperson of the partner if any """
        partner_rec = self.session.browse('res.partner', self.options.partner_id)
        if partner_rec.user_id:
            return {'user_id': partner_rec.user_id.id}
        return {'user_id': False}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants