mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-28 03:16:29 -06:00
[FIX]document_url_google_drive: Moved part of settings from res.users to general settings adn add used and added use module google_account
This commit is contained in:
parent
e5ce59e9b2
commit
0864db0ae0
@ -11,6 +11,7 @@
|
|||||||
"installable": True,
|
"installable": True,
|
||||||
"depends": [
|
"depends": [
|
||||||
"document_url",
|
"document_url",
|
||||||
|
"google_account",
|
||||||
],
|
],
|
||||||
"data": [
|
"data": [
|
||||||
"views/res_users_view.xml",
|
"views/res_users_view.xml",
|
||||||
|
@ -9,5 +9,18 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
|
|
||||||
is_active_google_api = fields.Boolean(
|
is_active_google_api = fields.Boolean(
|
||||||
string="Google APIs",
|
string="Google APIs",
|
||||||
config_parameter="document_url_google_drive.is_active_google_api",
|
config_parameter="is_active_google_api",
|
||||||
|
)
|
||||||
|
google_picker_client_id = fields.Char(
|
||||||
|
string="Google Client ID",
|
||||||
|
config_parameter="google_picker_client_id",
|
||||||
|
)
|
||||||
|
google_picker_api_key = fields.Char(
|
||||||
|
string="Google API Key",
|
||||||
|
config_parameter="google_picker_api_key",
|
||||||
|
)
|
||||||
|
google_picker_app_id = fields.Char(
|
||||||
|
string="Google App ID",
|
||||||
|
config_parameter="google_picker_app_id",
|
||||||
|
default="odoo",
|
||||||
)
|
)
|
||||||
|
@ -6,16 +6,11 @@ from odoo import fields, models
|
|||||||
|
|
||||||
class ResUsers(models.Model):
|
class ResUsers(models.Model):
|
||||||
_inherit = "res.users"
|
_inherit = "res.users"
|
||||||
google_picker_client_id = fields.Char(string="Google Client ID")
|
|
||||||
google_picker_api_key = fields.Char(string="Google API Key")
|
|
||||||
google_picker_scope = fields.Char(
|
google_picker_scope = fields.Char(
|
||||||
string="Google Scope",
|
string="Google Scope",
|
||||||
default="https://www.googleapis.com/auth/drive.readonly",
|
default="https://www.googleapis.com/auth/drive.readonly",
|
||||||
)
|
)
|
||||||
google_picker_app_id = fields.Char(
|
|
||||||
string="Google App ID",
|
|
||||||
default="odoo",
|
|
||||||
)
|
|
||||||
google_picker_access_token = fields.Char(string="Google Access Token")
|
google_picker_access_token = fields.Char(string="Google Access Token")
|
||||||
google_picker_mime_types = fields.Char(string="Google Mime Types")
|
google_picker_mime_types = fields.Char(string="Google Mime Types")
|
||||||
|
|
||||||
@ -25,18 +20,17 @@ class ResUsers(models.Model):
|
|||||||
:return: dict
|
:return: dict
|
||||||
"""
|
"""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
is_active_google_api = (
|
config = self.env["ir.config_parameter"].sudo()
|
||||||
self.env["ir.config_parameter"]
|
google_service = self.env["google.service"]
|
||||||
.sudo()
|
is_active_google_api = config.get_param("is_active_google_api")
|
||||||
.get_param("document_url_google_drive.is_active_google_api")
|
|
||||||
)
|
|
||||||
if not is_active_google_api:
|
if not is_active_google_api:
|
||||||
return {}
|
return {}
|
||||||
return {
|
return {
|
||||||
"client_id": self.google_picker_client_id,
|
"client_id": google_service._get_client_id("picker"),
|
||||||
"api_key": self.google_picker_api_key,
|
"api_key": config.get_param("google_picker_api_key"),
|
||||||
|
"app_id": config.get_param("google_picker_app_id"),
|
||||||
"scope": self.google_picker_scope,
|
"scope": self.google_picker_scope,
|
||||||
"app_id": self.google_picker_app_id,
|
|
||||||
"access_token": self.google_picker_access_token,
|
"access_token": self.google_picker_access_token,
|
||||||
"mime_types": self.google_picker_mime_types,
|
"mime_types": self.google_picker_mime_types,
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,16 @@ To configure this module, you need to:
|
|||||||
|
|
||||||
- Enable "Google API", save.
|
- Enable "Google API", save.
|
||||||
|
|
||||||
|
- field "Google Client ID" - enter the client ID from the Google API console.
|
||||||
|
- field "Google API key" - enter the API key from the Google API console.
|
||||||
|
- field "Google App ID" - enter the ID of the Google application. The default value is
|
||||||
|
`odoo`.
|
||||||
|
|
||||||
- Next, open your user profile and set up personal access credentials on the "Google
|
- Next, open your user profile and set up personal access credentials on the "Google
|
||||||
API" tab.
|
API" tab.
|
||||||
|
|
||||||
- field "Google Client ID" - enter the client ID from the Google API console.
|
|
||||||
- field "Google API key" - enter the API key from the Google API console.
|
|
||||||
- field "Google Scope" - enter the scope for the Google API. The default value is
|
- field "Google Scope" - enter the scope for the Google API. The default value is
|
||||||
`https://www.googleapis.com/auth/drive.readonly`.
|
`https://www.googleapis.com/auth/drive.readonly`.
|
||||||
- field "Google App ID" - enter the ID of the Google application. The default value is
|
|
||||||
`odoo`.
|
|
||||||
- field "Google Access Token" - your token will be displayed here. It is necessary to
|
- field "Google Access Token" - your token will be displayed here. It is necessary to
|
||||||
edit it.
|
edit it.
|
||||||
- field "Google Mime Types" - enter the file formats to be filtered when selecting.
|
- field "Google Mime Types" - enter the file formats to be filtered when selecting.
|
||||||
|
@ -66,7 +66,6 @@ export class AttachmentGooglePicker extends Component {
|
|||||||
this.state.accessToken = null;
|
this.state.accessToken = null;
|
||||||
await this.saveUserAuthAccessToken();
|
await this.saveUserAuthAccessToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// Private
|
// Private
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -84,7 +83,7 @@ export class AttachmentGooglePicker extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async saveUserAuthAccessToken() {
|
async saveUserAuthAccessToken() {
|
||||||
this.orm.call("res.users", "save_google_picker_access_token", [
|
await this.orm.call("res.users", "save_google_picker_access_token", [
|
||||||
this.user.userId,
|
this.user.userId,
|
||||||
this.state.accessToken,
|
this.state.accessToken,
|
||||||
]);
|
]);
|
||||||
@ -150,15 +149,15 @@ export class AttachmentGooglePicker extends Component {
|
|||||||
|
|
||||||
async pickerCallback(data) {
|
async pickerCallback(data) {
|
||||||
if (data.action === window.google.picker.Action.PICKED) {
|
if (data.action === window.google.picker.Action.PICKED) {
|
||||||
data[window.google.picker.Response.DOCUMENTS].forEach((document) => {
|
for (const document of data.docs) {
|
||||||
this.createAttachment(document);
|
await this.createAttachment(document);
|
||||||
});
|
}
|
||||||
await this._onAddedUrl();
|
await this._onAddedUrl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async createAttachment(document) {
|
async createAttachment(document) {
|
||||||
this.orm.call("ir.attachment.add_url", "add_attachment_google_drive", [
|
await this.orm.call("ir.attachment.add_url", "add_attachment_google_drive", [
|
||||||
document.url,
|
document.url,
|
||||||
document.name,
|
document.name,
|
||||||
this.props.record.chatter.thread.model,
|
this.props.record.chatter.thread.model,
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
Add GDrive link
|
Add GDrive link
|
||||||
|
|
||||||
</button>
|
</button>
|
||||||
<i
|
<i
|
||||||
t-if="state.accessToken"
|
t-if="state.accessToken"
|
||||||
class="fa fa-sign-out"
|
class="fa fa-sign-out"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
|
@ -19,6 +19,35 @@
|
|||||||
<div class="text-muted">
|
<div class="text-muted">
|
||||||
Use google integration.
|
Use google integration.
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="content-group"
|
||||||
|
attrs="{'invisible': [('is_active_google_api','=',False)]}"
|
||||||
|
>
|
||||||
|
<div class="mt16 row">
|
||||||
|
<label
|
||||||
|
for="google_picker_client_id"
|
||||||
|
string="Google Client ID"
|
||||||
|
class="col-3 col-lg-3 o_light_label"
|
||||||
|
/>
|
||||||
|
<field name="google_picker_client_id" nolabel="1" />
|
||||||
|
</div>
|
||||||
|
<div class="mt16 row">
|
||||||
|
<label
|
||||||
|
for="google_picker_api_key"
|
||||||
|
string="Google Api Key"
|
||||||
|
class="col-3 col-lg-3 o_light_label"
|
||||||
|
/>
|
||||||
|
<field name="google_picker_api_key" nolabel="1" />
|
||||||
|
</div>
|
||||||
|
<div class="mt16 row">
|
||||||
|
<label
|
||||||
|
for="google_picker_app_id"
|
||||||
|
string="Google App Id"
|
||||||
|
class="col-3 col-lg-3 o_light_label"
|
||||||
|
/>
|
||||||
|
<field name="google_picker_app_id" nolabel="1" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
@ -11,10 +11,7 @@
|
|||||||
<xpath expr="//notebook" position="inside">
|
<xpath expr="//notebook" position="inside">
|
||||||
<page string="Google API">
|
<page string="Google API">
|
||||||
<group>
|
<group>
|
||||||
<field name="google_picker_client_id" />
|
|
||||||
<field name="google_picker_api_key" />
|
|
||||||
<field name="google_picker_scope" />
|
<field name="google_picker_scope" />
|
||||||
<field name="google_picker_app_id" />
|
|
||||||
<field name="google_picker_access_token" readonly="1" />
|
<field name="google_picker_access_token" readonly="1" />
|
||||||
<field name="google_picker_mime_types" />
|
<field name="google_picker_mime_types" />
|
||||||
</group>
|
</group>
|
||||||
|
Loading…
Reference in New Issue
Block a user