mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-21 00:52:03 +02:00
Initial commit: Core packages
This commit is contained in:
commit
12c29a983b
9512 changed files with 8379910 additions and 0 deletions
|
|
@ -0,0 +1,48 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { registerPatch } from '@mail/model/model_core';
|
||||
import { one } from '@mail/model/model_field';
|
||||
import { clear } from '@mail/model/model_field_command';
|
||||
|
||||
registerPatch({
|
||||
name: 'Dialog',
|
||||
fields: {
|
||||
componentClassName: {
|
||||
compute() {
|
||||
if (this.snailmailErrorView) {
|
||||
return 'o_Dialog_componentMediumSize align-self-start mt-5';
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
},
|
||||
componentName: {
|
||||
compute() {
|
||||
if (this.snailmailErrorView) {
|
||||
return 'SnailmailError';
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
},
|
||||
messageViewOwnerAsSnailmailError: one('MessageView', {
|
||||
identifying: true,
|
||||
inverse: 'snailmailErrorDialog',
|
||||
}),
|
||||
record: {
|
||||
compute() {
|
||||
if (this.snailmailErrorView) {
|
||||
return this.snailmailErrorView;
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
},
|
||||
snailmailErrorView: one('SnailmailErrorView', {
|
||||
compute() {
|
||||
if (this.messageViewOwnerAsSnailmailError) {
|
||||
return {};
|
||||
}
|
||||
return clear();
|
||||
},
|
||||
inverse: 'dialogOwner',
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { registerPatch } from '@mail/model/model_core';
|
||||
|
||||
registerPatch({
|
||||
name: 'Message',
|
||||
recordMethods: {
|
||||
/**
|
||||
* Cancels the 'snailmail.letter' corresponding to this message.
|
||||
*
|
||||
* @returns {Deferred}
|
||||
*/
|
||||
async cancelLetter() {
|
||||
// the result will come from the bus: message_notification_update
|
||||
await this.messaging.rpc({
|
||||
model: 'mail.message',
|
||||
method: 'cancel_letter',
|
||||
args: [[this.id]],
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Opens the action about 'snailmail.letter' format error.
|
||||
*/
|
||||
openFormatLetterAction() {
|
||||
this.env.services.action.doAction(
|
||||
'snailmail.snailmail_letter_format_error_action',
|
||||
{
|
||||
additionalContext: {
|
||||
message_id: this.id,
|
||||
},
|
||||
},
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Opens the action about 'snailmail.letter' missing fields.
|
||||
*/
|
||||
async openMissingFieldsLetterAction() {
|
||||
const letterIds = await this.messaging.rpc({
|
||||
model: 'snailmail.letter',
|
||||
method: 'search',
|
||||
args: [[['message_id', '=', this.id]]],
|
||||
});
|
||||
this.env.services.action.doAction(
|
||||
'snailmail.snailmail_letter_missing_required_fields_action',
|
||||
{
|
||||
additionalContext: {
|
||||
default_letter_id: letterIds[0],
|
||||
},
|
||||
}
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Retries to send the 'snailmail.letter' corresponding to this message.
|
||||
*/
|
||||
async resendLetter() {
|
||||
// the result will come from the bus: message_notification_update
|
||||
await this.messaging.rpc({
|
||||
model: 'mail.message',
|
||||
method: 'send_letter',
|
||||
args: [[this.id]],
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { registerPatch } from '@mail/model/model_core';
|
||||
import { one } from '@mail/model/model_field';
|
||||
import { clear } from '@mail/model/model_field_command';
|
||||
|
||||
registerPatch({
|
||||
name: 'MessageView',
|
||||
recordMethods: {
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
onClickFailure() {
|
||||
if (this.message.message_type === 'snailmail') {
|
||||
/**
|
||||
* Messages from snailmail are considered to have at most one
|
||||
* notification. The failure type of the whole message is considered
|
||||
* to be the same as the one from that first notification, and the
|
||||
* click action will depend on it.
|
||||
*/
|
||||
switch (this.message.notifications[0].failure_type) {
|
||||
case 'sn_credit':
|
||||
// URL only used in this component, not received at init
|
||||
this.messaging.fetchSnailmailCreditsUrl();
|
||||
this.update({ snailmailErrorDialog: {} });
|
||||
break;
|
||||
case 'sn_error':
|
||||
this.update({ snailmailErrorDialog: {} });
|
||||
break;
|
||||
case 'sn_fields':
|
||||
this.message.openMissingFieldsLetterAction();
|
||||
break;
|
||||
case 'sn_format':
|
||||
this.message.openFormatLetterAction();
|
||||
break;
|
||||
case 'sn_price':
|
||||
this.update({ snailmailErrorDialog: {} });
|
||||
break;
|
||||
case 'sn_trial':
|
||||
// URL only used in this component, not received at init
|
||||
this.messaging.fetchSnailmailCreditsUrlTrial();
|
||||
this.update({ snailmailErrorDialog: {} });
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
this._super(...arguments);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
onClickNotificationIcon() {
|
||||
if (this.message && this.message.message_type === 'snailmail') {
|
||||
this.update({ snailmailNotificationPopoverView: this.snailmailNotificationPopoverView ? clear() : {} });
|
||||
return;
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
},
|
||||
fields: {
|
||||
failureNotificationIconClassName: {
|
||||
compute() {
|
||||
if (this.message && this.message.message_type === 'snailmail') {
|
||||
return 'fa fa-paper-plane';
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
},
|
||||
notificationIconClassName: {
|
||||
compute() {
|
||||
if (this.message && this.message.message_type === 'snailmail') {
|
||||
return 'fa fa-paper-plane';
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
},
|
||||
snailmailErrorDialog: one('Dialog', {
|
||||
inverse: 'messageViewOwnerAsSnailmailError',
|
||||
}),
|
||||
snailmailNotificationPopoverView: one('PopoverView', {
|
||||
inverse: 'messageViewOwnerAsSnailmailNotificationContent',
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { registerPatch } from '@mail/model/model_core';
|
||||
import { attr } from '@mail/model/model_field';
|
||||
|
||||
registerPatch({
|
||||
name: 'Messaging',
|
||||
recordMethods: {
|
||||
async fetchSnailmailCreditsUrl() {
|
||||
const snailmail_credits_url = await this.messaging.rpc({
|
||||
model: 'iap.account',
|
||||
method: 'get_credits_url',
|
||||
args: ['snailmail'],
|
||||
});
|
||||
if (!this.exists()) {
|
||||
return;
|
||||
}
|
||||
this.update({
|
||||
snailmail_credits_url,
|
||||
});
|
||||
},
|
||||
async fetchSnailmailCreditsUrlTrial() {
|
||||
const snailmail_credits_url_trial = await this.messaging.rpc({
|
||||
model: 'iap.account',
|
||||
method: 'get_credits_url',
|
||||
args: ['snailmail', '', 0, true],
|
||||
});
|
||||
if (!this.exists()) {
|
||||
return;
|
||||
}
|
||||
this.update({
|
||||
snailmail_credits_url_trial,
|
||||
});
|
||||
},
|
||||
},
|
||||
fields: {
|
||||
snailmail_credits_url: attr(),
|
||||
snailmail_credits_url_trial: attr(),
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { registerPatch } from '@mail/model/model_core';
|
||||
|
||||
registerPatch({
|
||||
name: 'NotificationGroup',
|
||||
recordMethods: {
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_openDocuments() {
|
||||
if (this.notification_type !== 'snail') {
|
||||
return this._super(...arguments);
|
||||
}
|
||||
this.env.services.action.doAction({
|
||||
name: this.env._t("Snailmail Failures"),
|
||||
type: 'ir.actions.act_window',
|
||||
view_mode: 'kanban,list,form',
|
||||
views: [[false, 'kanban'], [false, 'list'], [false, 'form']],
|
||||
target: 'current',
|
||||
res_model: this.res_model,
|
||||
domain: [['message_ids.snailmail_error', '=', true]],
|
||||
});
|
||||
if (this.messaging.device.isSmall) {
|
||||
// messaging menu has a higher z-index than views so it must
|
||||
// be closed to ensure the visibility of the view
|
||||
this.messaging.messagingMenu.close();
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { registerPatch } from '@mail/model/model_core';
|
||||
|
||||
registerPatch({
|
||||
name: 'NotificationGroupView',
|
||||
fields: {
|
||||
imageSrc: {
|
||||
compute() {
|
||||
if (this.notificationGroup.notification_type === 'snail') {
|
||||
return '/snailmail/static/img/snailmail_failure.png';
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { registerPatch } from '@mail/model/model_core';
|
||||
import { one } from '@mail/model/model_field';
|
||||
import { clear } from '@mail/model/model_field_command';
|
||||
|
||||
registerPatch({
|
||||
name: 'PopoverView',
|
||||
fields: {
|
||||
anchorRef: {
|
||||
compute() {
|
||||
if (this.messageViewOwnerAsSnailmailNotificationContent) {
|
||||
return this.messageViewOwnerAsSnailmailNotificationContent.notificationIconRef;
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
},
|
||||
content: {
|
||||
compute() {
|
||||
if (this.snailmailNotificationPopoverContentView) {
|
||||
return this.snailmailNotificationPopoverContentView;
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
},
|
||||
contentComponentName: {
|
||||
compute() {
|
||||
if (this.snailmailNotificationPopoverContentView) {
|
||||
return 'SnailmailNotificationPopoverContentView';
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
},
|
||||
messageViewOwnerAsSnailmailNotificationContent: one('MessageView', {
|
||||
identifying: true,
|
||||
inverse: 'snailmailNotificationPopoverView',
|
||||
}),
|
||||
snailmailNotificationPopoverContentView: one('SnailmailNotificationPopoverContentView', {
|
||||
compute() {
|
||||
if (this.messageViewOwnerAsSnailmailNotificationContent) {
|
||||
return {};
|
||||
}
|
||||
return clear();
|
||||
},
|
||||
inverse: 'popoverViewOwner',
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { registerModel } from '@mail/model/model_core';
|
||||
import { attr, one } from '@mail/model/model_field';
|
||||
|
||||
registerModel({
|
||||
name: 'SnailmailErrorView',
|
||||
recordMethods: {
|
||||
/**
|
||||
* Returns whether the given html element is inside this snailmail error view.
|
||||
*
|
||||
* @param {Element} element
|
||||
* @returns {boolean}
|
||||
*/
|
||||
containsElement(element) {
|
||||
return Boolean(this.component && this.component.root.el && this.component.root.el.contains(element));
|
||||
},
|
||||
onClickCancelLetter() {
|
||||
this.message.cancelLetter();
|
||||
this.dialogOwner.delete();
|
||||
},
|
||||
onClickClose() {
|
||||
this.dialogOwner.delete();
|
||||
},
|
||||
onClickResendLetter() {
|
||||
this.message.resendLetter();
|
||||
this.dialogOwner.delete();
|
||||
},
|
||||
},
|
||||
fields: {
|
||||
component: attr(),
|
||||
dialogOwner: one('Dialog', {
|
||||
identifying: true,
|
||||
inverse: 'snailmailErrorView',
|
||||
}),
|
||||
hasCreditsError: attr({
|
||||
compute() {
|
||||
return Boolean(
|
||||
this.notification &&
|
||||
(
|
||||
this.notification.failure_type === 'sn_credit' ||
|
||||
this.notification.failure_type === 'sn_trial'
|
||||
)
|
||||
);
|
||||
},
|
||||
}),
|
||||
message: one('Message', {
|
||||
compute() {
|
||||
return this.dialogOwner.messageViewOwnerAsSnailmailError.message;
|
||||
},
|
||||
required: true,
|
||||
}),
|
||||
/**
|
||||
* Messages from snailmail are considered to have at most one notification.
|
||||
*/
|
||||
notification: one('Notification', {
|
||||
compute() {
|
||||
return this.message.notifications[0];
|
||||
},
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { registerModel } from '@mail/model/model_core';
|
||||
import { attr, one } from '@mail/model/model_field';
|
||||
import { clear } from '@mail/model/model_field_command';
|
||||
|
||||
registerModel({
|
||||
name: 'SnailmailNotificationPopoverContentView',
|
||||
fields: {
|
||||
iconClass: attr({
|
||||
compute() {
|
||||
if (!this.notification) {
|
||||
return clear();
|
||||
}
|
||||
switch (this.notification.notification_status) {
|
||||
case 'sent':
|
||||
return 'fa fa-check';
|
||||
case 'ready':
|
||||
return 'fa fa-clock-o';
|
||||
case 'canceled':
|
||||
return 'fa fa-trash-o';
|
||||
default:
|
||||
return 'fa fa-exclamation text-danger';
|
||||
}
|
||||
},
|
||||
default: '',
|
||||
}),
|
||||
iconTitle: attr({
|
||||
compute() {
|
||||
if (!this.notification) {
|
||||
return clear();
|
||||
}
|
||||
switch (this.notification.notification_status) {
|
||||
case 'sent':
|
||||
return this.env._t("Sent");
|
||||
case 'ready':
|
||||
return this.env._t("Awaiting Dispatch");
|
||||
case 'canceled':
|
||||
return this.env._t("Canceled");
|
||||
default:
|
||||
return this.env._t("Error");
|
||||
}
|
||||
},
|
||||
default: '',
|
||||
}),
|
||||
message: one('Message', {
|
||||
compute() {
|
||||
return this.popoverViewOwner.messageViewOwnerAsSnailmailNotificationContent.message;
|
||||
},
|
||||
}),
|
||||
notification: one('Notification', {
|
||||
compute() {
|
||||
if (!this.message) {
|
||||
return clear();
|
||||
}
|
||||
// Messages from snailmail are considered to have at most one notification.
|
||||
return this.message.notifications[0];
|
||||
},
|
||||
}),
|
||||
popoverViewOwner: one('PopoverView', {
|
||||
identifying: true,
|
||||
inverse: 'snailmailNotificationPopoverContentView',
|
||||
}),
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue