mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-18 20:32:03 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,53 @@
|
|||
/** @odoo-module */
|
||||
|
||||
import {Component} from "@odoo/owl";
|
||||
import {FormLabel} from "@web/views/form/form_label";
|
||||
import Popover from "web.Popover";
|
||||
|
||||
export class BaseChangesetPopover extends Popover {
|
||||
/*
|
||||
Call the ORM to accept the change and refresh the form view
|
||||
to update the field value.
|
||||
*/
|
||||
async applyChange(change_id) {
|
||||
await this.props.record.model.orm.call(
|
||||
"record.changeset.change",
|
||||
"apply",
|
||||
[[change_id]],
|
||||
{
|
||||
context: {set_change_by_ui: true},
|
||||
}
|
||||
);
|
||||
this._close();
|
||||
// Save the record first to prevent losing unsaved data on load.
|
||||
await this.props.record.save();
|
||||
await this.props.record.load();
|
||||
await this.props.record.model.notify();
|
||||
}
|
||||
/*
|
||||
Call the ORM to reject the change and only update the record's pending changes.
|
||||
*/
|
||||
async rejectChange(change_id) {
|
||||
await this.props.record.model.orm.call(
|
||||
"record.changeset.change",
|
||||
"cancel",
|
||||
[[change_id]],
|
||||
{
|
||||
context: {set_change_by_ui: true},
|
||||
}
|
||||
);
|
||||
this._close();
|
||||
this.props.record.changesetChanges =
|
||||
await this.props.record.fetchChangesetChanges();
|
||||
this.props.record.model.notify();
|
||||
}
|
||||
}
|
||||
BaseChangesetPopover.template = "base_changeset.ChangesetPopover";
|
||||
BaseChangesetPopover.props = ["fieldName", "popoverClass", "record", "title"];
|
||||
|
||||
export class BaseChangesetPopoverWrapper extends Component {}
|
||||
BaseChangesetPopoverWrapper.components = {BaseChangesetPopover};
|
||||
BaseChangesetPopoverWrapper.template = "base_changeset.ChangesetPopoverWrapper";
|
||||
|
||||
FormLabel.components = FormLabel.components || {};
|
||||
Object.assign(FormLabel.components, {BaseChangesetPopoverWrapper});
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
.o_changeset_popover {
|
||||
background-color: $o-view-background-color;
|
||||
}
|
||||
span.o_changeset_popover_wrapper > div {
|
||||
display: inline;
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="base_changeset.ChangesetPopoverWrapper" owl="1">
|
||||
<!--
|
||||
The popover button has to be set to inline display using a wrapper around
|
||||
the inherited Popover template. Otherwise, if instead we modify the top
|
||||
level div element of the Popover template, the component loses its `el`.
|
||||
-->
|
||||
<span class="o_changeset_popover_wrapper">
|
||||
<BaseChangesetPopover
|
||||
record="props.record"
|
||||
fieldName="props.fieldName"
|
||||
title="'Pending Changes'"
|
||||
popoverClass="'o_changeset_popover'"
|
||||
t-if="props.record.changesetChanges ? props.record.changesetChanges[props.fieldName] : 0"
|
||||
/>
|
||||
</span>
|
||||
</t>
|
||||
<t
|
||||
t-name="base_changeset.ChangesetPopover"
|
||||
owl="1"
|
||||
t-inherit="web.Popover"
|
||||
t-inherit-mode="primary"
|
||||
>
|
||||
<t t-portal="'body'" position="before">
|
||||
<a
|
||||
class="o_ChangesetPopoverView badge rounded-pill text-bg-warning mx-3 align-self-center"
|
||||
t-esc="props.record.changesetChanges[props.fieldName].length"
|
||||
role="button"
|
||||
/>
|
||||
</t>
|
||||
<t t-slot="opened" position="replace">
|
||||
<table class="pb-4">
|
||||
<tr
|
||||
t-foreach="props.record.changesetChanges[props.fieldName]"
|
||||
t-as="change"
|
||||
t-key="change.id"
|
||||
>
|
||||
<td>
|
||||
<t t-esc="change.origin_value_display" />
|
||||
</td>
|
||||
<td class="pl-2 pr-2">
|
||||
<i class="fa fa-arrow-right" />
|
||||
</td>
|
||||
<td>
|
||||
<t t-esc="change.new_value_display" />
|
||||
</td>
|
||||
<td class="pl-4" t-if="change.user_can_validate_changeset">
|
||||
<div class="btn-group">
|
||||
<button
|
||||
class="btn btn-danger base_changeset_reject btn-sm"
|
||||
t-attf-data-id="#{change.id}"
|
||||
t-on-click.synthetic="() => this.rejectChange(change.id)"
|
||||
>
|
||||
<i class="fa fa-times" />
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-success base_changeset_apply btn-sm"
|
||||
t-attf-data-id="#{change.id}"
|
||||
t-on-click.synthetic="() => this.applyChange(change.id)"
|
||||
>
|
||||
<i class="fa fa-check" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-inherit="web.FormLabel" t-inherit-mode="extension">
|
||||
<xpath expr="//label" position="inside">
|
||||
<BaseChangesetPopoverWrapper record="props.record" fieldName="props.id" />
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/* @odoo-module */
|
||||
|
||||
import {Record} from "@web/views/basic_relational_model";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(Record.prototype, "base_changeset.Record", {
|
||||
/* Call the ORM to get this record's changeset changes */
|
||||
async fetchChangesetChanges() {
|
||||
return this.model.orm.call(
|
||||
"record.changeset.change",
|
||||
"get_changeset_changes_by_field",
|
||||
[this.resModel, this.resId]
|
||||
);
|
||||
},
|
||||
/* After loading the form's record data, fetch the changeset changes */
|
||||
async load() {
|
||||
await this._super(...arguments);
|
||||
if (this.__viewType === "form" && this.resId) {
|
||||
this.changesetChanges = await this.fetchChangesetChanges();
|
||||
}
|
||||
},
|
||||
/* Call the ORM to get this record's changeset changes after the form is modified */
|
||||
async save() {
|
||||
const isSaved = await this._super(...arguments);
|
||||
if (this.__viewType === "form" && this.resId) {
|
||||
this.changesetChanges = await this.fetchChangesetChanges();
|
||||
this.model.notify();
|
||||
}
|
||||
return isSaved;
|
||||
},
|
||||
});
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
Loading…
Add table
Add a link
Reference in a new issue