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

[IMP] add helper for getting a self env with the tech user #1824

Merged
merged 1 commit into from
Apr 24, 2020

Conversation

sebastienbeau
Copy link
Member

No description provided.

@sebastienbeau
Copy link
Member Author

@acsonefho @Cedric-Pigeon

Copy link

@Cedric-Pigeon Cedric-Pigeon left a comment

Choose a reason for hiding this comment

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

code review. Thanks

@sebastienbeau sebastienbeau force-pushed the 10.0-base_technical_user_helper branch from 6a12997 to e13fd3b Compare April 24, 2020 13:38
Copy link
Contributor

@acsonefho acsonefho left a comment

Choose a reason for hiding this comment

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

Great! Just one question

return self_sudoer


models.BaseModel.sudo_tech = sudo_tech
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not doing like this:

class Base(models.AbstractModel):
    _inherit = 'base'

    def sudo_tech(self, raise_if_missing=False):
        self_sudoer = self
        tech_user = self.env.user.company_id.user_tech_id
        if tech_user:
            self_sudoer = self.sudo(tech_user.id)
        elif raise_if_missing:
            raise UserError("The technical user is missing in the company {}".format(self.env.user.company_id.name))
        return self_sudoer

It's more "Odoo"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry I mix the version. I was think that this was not possible on 10 and only work since 11. But it's work since 9. I fix it

@sebastienbeau sebastienbeau force-pushed the 10.0-base_technical_user_helper branch from e13fd3b to bbf07b7 Compare April 24, 2020 14:40
@sebastienbeau sebastienbeau force-pushed the 10.0-base_technical_user_helper branch from bbf07b7 to 7540fe7 Compare April 24, 2020 15:01
@sebastienbeau
Copy link
Member Author

@simahawk fixed !

Copy link
Contributor

@acsonefho acsonefho left a comment

Choose a reason for hiding this comment

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

Nice!

@sebastienbeau sebastienbeau force-pushed the 10.0-base_technical_user_helper branch from 7540fe7 to 266d809 Compare April 24, 2020 16:15
@sebastienbeau
Copy link
Member Author

/ocabot merge minor

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 10.0-ocabot-merge-pr-1824-by-sebastienbeau-bump-minor, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 87c4c74 into OCA:10.0 Apr 24, 2020
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 9636d1a. Thanks a lot for contributing to OCA. ❤️

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.

5 participants