-
-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from akretion/16.0-add-fastapi-auth-impersonate
[IMP] fastapi_auth_partner: Add impersonations
- Loading branch information
Showing
13 changed files
with
274 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
|
||
<record id="fastapi_endpoint_view_form" model="ir.ui.view"> | ||
<field name="model">fastapi.endpoint</field> | ||
<field name="inherit_id" ref="fastapi.fastapi_endpoint_form_view" /> | ||
<field name="arch" type="xml"> | ||
<field name="demo_auth_method" position="after"> | ||
<field | ||
<record id="fastapi_endpoint_view_form" model="ir.ui.view"> | ||
<field name="model">fastapi.endpoint</field> | ||
<field name="inherit_id" ref="fastapi.fastapi_endpoint_form_view" /> | ||
<field name="arch" type="xml"> | ||
<field name="demo_auth_method" position="after"> | ||
<field name="is_partner_auth" invisible="1" /> | ||
<field | ||
name="directory_id" | ||
attrs="{ | ||
'invisible': [('demo_auth_method', '!=', 'auth_partner')], | ||
'required': [('demo_auth_method', '=', 'auth_partner')] | ||
}" | ||
'invisible': [('is_partner_auth', '=', False)], | ||
'required': [('is_partner_auth', '=', True)] | ||
}" | ||
/> | ||
</field> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
|
||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import wizard_partner_auth_reset_password | ||
from . import wizard_partner_auth_impersonate |
29 changes: 29 additions & 0 deletions
29
fastapi_auth_partner/wizards/wizard_partner_auth_impersonate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2024 Akretion (http://www.akretion.com). | ||
# @author Florian Mounier <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
|
||
from odoo import fields, models | ||
|
||
|
||
class WizardPartnerAuthImpersonate(models.TransientModel): | ||
_name = "wizard.partner.auth.impersonate" | ||
_description = "Wizard Partner Auth Impersonate" | ||
|
||
fastapi_auth_partner_id = fields.Many2one( | ||
"fastapi.auth.partner", | ||
required=True, | ||
) | ||
fastapi_auth_directory_id = fields.Many2one( | ||
"fastapi.auth.directory", | ||
related="fastapi_auth_partner_id.directory_id", | ||
) | ||
fastapi_endpoint_id = fields.Many2one( | ||
"fastapi.endpoint", | ||
required=True, | ||
) | ||
|
||
def action_impersonate(self): | ||
return self.fastapi_auth_partner_id.with_context( | ||
fastapi_endpoint_id=self.fastapi_endpoint_id.id | ||
).impersonate() |
Oops, something went wrong.