mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
add sale commission
This commit is contained in:
@@ -64,7 +64,7 @@
|
|||||||
],
|
],
|
||||||
'assets': {
|
'assets': {
|
||||||
'mail.assets_messaging': [
|
'mail.assets_messaging': [
|
||||||
'app_chatgpt/static/src/models/*.js',
|
'app_chatgpt/static/src/models/message.js',
|
||||||
],
|
],
|
||||||
'mail.assets_model_data': [
|
'mail.assets_model_data': [
|
||||||
'app_chatgpt/static/src/models_data/*.js',
|
'app_chatgpt/static/src/models_data/*.js',
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<templates xml:space="preserve">
|
<templates xml:space="preserve">
|
||||||
<t t-name="app_chatgpt.Message" t-inherit="mail.Message" t-inherit-mode="extension">
|
<t t-name="app_chatgpt.Message" t-inherit="mail.Message" t-inherit-mode="extension">
|
||||||
<xpath expr="//div[hasclass('o_Message_prettyBody')]//.." position="replace">
|
<xpath expr="//Composer[@composer='message.composer']" position="after">
|
||||||
<t t-if="!messageView.composerViewInEditing">
|
<div t-if="state.isEditing" name="bottom_operation" class="position-relative mt-8">
|
||||||
<div class="o_Message_prettyBody" t-ref="prettyBody"/><!-- messageView.message.prettyBody is inserted here from _update() -->
|
<div t-if="message.human_prompt_tokens > 0 or message.ai_completion_tokens >0"
|
||||||
<div name="bottom_operation" class="position-relative mt-8">
|
|
||||||
<div t-if="messageView.message.human_prompt_tokens > 0 or messageView.message.ai_completion_tokens >0"
|
|
||||||
class="o_Message_token text-muted" style="float:left;display:inline;font-size: 13px;">
|
class="o_Message_token text-muted" style="float:left;display:inline;font-size: 13px;">
|
||||||
<br/>
|
<br/>
|
||||||
------------------
|
------------------
|
||||||
<br/>
|
<br/>
|
||||||
<span title="提问/答复 消耗Token">
|
<span title="提问/答复 消耗Token">
|
||||||
<t t-esc="messageView.message.human_prompt_tokens"/> / <t t-esc="messageView.message.ai_completion_tokens"/>
|
<t t-esc="message.human_prompt_tokens"/>
|
||||||
|
/
|
||||||
|
<t t-esc="message.ai_completion_tokens"/>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</t>
|
|
||||||
</xpath>
|
</xpath>
|
||||||
</t>
|
</t>
|
||||||
</templates>
|
</templates>
|
||||||
@@ -1,48 +1,64 @@
|
|||||||
/** @odoo-module **/
|
/** @odoo-module **/
|
||||||
|
|
||||||
import { insert } from '@mail/model/model_field_command';
|
import { EmojiPicker } from "@web/core/emoji_picker/emoji_picker";
|
||||||
import { getBundle, loadBundle } from '@web/core/assets';
|
import { loader } from "@web/core/emoji_picker/emoji_picker";
|
||||||
import { registerPatch } from '@mail/model/model_core';
|
|
||||||
|
|
||||||
registerPatch({
|
|
||||||
name: 'EmojiRegistry',
|
patch(EmojiPicker.prototype, {
|
||||||
recordMethods: {
|
async loadEmoji() {
|
||||||
async loadEmojiData() {
|
try {
|
||||||
this.update({isLoading: true});
|
await loader.loadEmoji();
|
||||||
await getBundle('mail.assets_model_data').then(loadBundle);
|
return odoo.loader.modules.get("@web/core/emoji_picker/emoji_data");
|
||||||
//优化 data 文件
|
} catch {
|
||||||
const {emojiCategoriesData, emojisData} = await odoo.runtimeImport("@app_chatgpt/models_data/emoji_data");
|
// Could be intentional (tour ended successfully while emoji still loading)
|
||||||
if (!this.exists()) {
|
return {emojis: [], categories: []};
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
this._populateFromEmojiData(emojiCategoriesData, emojisData);
|
|
||||||
},
|
},
|
||||||
async _populateFromEmojiData(dataCategories, dataEmojis) {
|
});
|
||||||
dataCategories.map(category => {
|
|
||||||
const emojiCount = dataEmojis.reduce((acc, emoji) => emoji.category === category.name ? acc + 1 : acc, 0);
|
// import { insert } from '@mail/model/model_field_command';
|
||||||
this.update({
|
// import { getBundle, loadBundle} from '@web/core/assets';
|
||||||
dataCategories: insert({
|
// import {registerPatch} from '@mail/model/model_core';
|
||||||
name: category.name,
|
//
|
||||||
displayName: category.displayName,
|
// registerPatch({
|
||||||
title: category.title,
|
// name: 'EmojiRegistry',
|
||||||
sortId: category.sortId,
|
// recordMethods: {
|
||||||
emojiCount,
|
// async loadEmojiData() {
|
||||||
}),
|
// this.update({isLoading: true});
|
||||||
});
|
// await getBundle('mail.assets_model_data').then(loadBundle);
|
||||||
});
|
// //优化 data 文件
|
||||||
this.models['Emoji'].insert(dataEmojis.map(emojiData => ({
|
// const {emojiCategoriesData, emojisData} = await odoo.runtimeImport("@app_chatgpt/models_data/emoji_data");
|
||||||
codepoints: emojiData.codepoints,
|
// if (!this.exists()) {
|
||||||
shortcodes: emojiData.shortcodes,
|
// return;
|
||||||
emoticons: emojiData.emoticons,
|
// }
|
||||||
name: emojiData.name,
|
// this._populateFromEmojiData(emojiCategoriesData, emojisData);
|
||||||
keywords: emojiData.keywords,
|
// },
|
||||||
emojiDataCategory: {name: emojiData.category},
|
// async _populateFromEmojiData(dataCategories, dataEmojis) {
|
||||||
})));
|
// dataCategories.map(category => {
|
||||||
this.update({
|
// const emojiCount = dataEmojis.reduce((acc, emoji) => emoji.category === category.name ? acc + 1 : acc, 0);
|
||||||
isLoaded: true,
|
// this.update({
|
||||||
isLoading: false,
|
// dataCategories: insert({
|
||||||
});
|
// name: category.name,
|
||||||
},
|
// displayName: category.displayName,
|
||||||
},
|
// title: category.title,
|
||||||
}
|
// sortId: category.sortId,
|
||||||
)
|
// emojiCount,
|
||||||
|
// }),
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// this.models['Emoji'].insert(dataEmojis.map(emojiData => ({
|
||||||
|
// codepoints: emojiData.codepoints,
|
||||||
|
// shortcodes: emojiData.shortcodes,
|
||||||
|
// emoticons: emojiData.emoticons,
|
||||||
|
// name: emojiData.name,
|
||||||
|
// keywords: emojiData.keywords,
|
||||||
|
// emojiDataCategory: {name: emojiData.category},
|
||||||
|
// })));
|
||||||
|
// this.update({
|
||||||
|
// isLoaded: true,
|
||||||
|
// isLoading: false,
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
// )
|
||||||
|
|||||||
@@ -1,30 +1,37 @@
|
|||||||
/** @odoo-module **/
|
/** @odoo-module **/
|
||||||
|
import { Message } from "@mail/core/common/message_model";
|
||||||
|
|
||||||
import { insert } from '@mail/model/model_field_command';
|
patch(Message, {
|
||||||
import { attr, many, one } from '@mail/model/model_field';
|
/** @type {number} */
|
||||||
import { registerPatch } from '@mail/model/model_core';
|
human_prompt_tokens,
|
||||||
|
/** @type {number} */
|
||||||
|
ai_completion_tokens,
|
||||||
|
/** @type {boolean} */
|
||||||
|
is_ai,
|
||||||
|
});
|
||||||
|
|
||||||
registerPatch({
|
//
|
||||||
name: 'Message',
|
// registerPatch({
|
||||||
modelMethods: {
|
// name: 'Message',
|
||||||
convertData(data) {
|
// modelMethods: {
|
||||||
const data2 = this._super(data);
|
// convertData(data) {
|
||||||
if ('human_prompt_tokens' in data) {
|
// const data2 = this._super(data);
|
||||||
data2.human_prompt_tokens = data.human_prompt_tokens;
|
// if ('human_prompt_tokens' in data) {
|
||||||
}
|
// data2.human_prompt_tokens = data.human_prompt_tokens;
|
||||||
if ('ai_completion_tokens' in data) {
|
// }
|
||||||
data2.ai_completion_tokens = data.ai_completion_tokens;
|
// if ('ai_completion_tokens' in data) {
|
||||||
}
|
// data2.ai_completion_tokens = data.ai_completion_tokens;
|
||||||
if ('is_ai' in data) {
|
// }
|
||||||
data2.is_ai = data.is_ai;
|
// if ('is_ai' in data) {
|
||||||
}
|
// data2.is_ai = data.is_ai;
|
||||||
return data2;
|
// }
|
||||||
},
|
// return data2;
|
||||||
},
|
// },
|
||||||
fields: {
|
// },
|
||||||
human_prompt_tokens: attr(),
|
// fields: {
|
||||||
ai_completion_tokens: attr(),
|
// human_prompt_tokens: attr(),
|
||||||
is_ai: attr(),
|
// ai_completion_tokens: attr(),
|
||||||
|
// is_ai: attr(),
|
||||||
}
|
//
|
||||||
})
|
// }
|
||||||
|
// })
|
||||||
Reference in New Issue
Block a user