Se rendre au contenu
Menu
Cette question a été signalée
604 Vues

Is there any settings or config to manual edit button for odoo 17. I am trying many 3rd party modules for edit save button in odoo 17. but it is working for only form view field I can not edit list view field inside form view. how can I modify both form view field and one2many list view field. please help me 
here this js i can only edit the form view field 

/** @odoo-module **/
import { patch } from "@web/core/utils/patch";
import { FormController } from "@web/views/form/form_controller";

import { registry } from "@web/core/registry";
const viewRegistry = registry.category("views");

const originalSetup = FormController.prototype.setup;
const originalEdit = FormController.prototype.edit;
const originalSaveButtonClicked = FormController.prototype.saveButtonClicked;
const originalDiscard = FormController.prototype.discard;

import { jsonrpc } from "@web/core/network/rpc_service";

odoo.__DEBUG__ && console.log("Console log inside the patch function", FormController.prototype, "form_controller");

patch(FormController.prototype, {
setup() {
this.props.preventEdit = this.env.inDialog ? false : true;
originalSetup.call(this);
},


async edit() {
if (originalEdit) {
await originalEdit.call(this);
}

if (this.model && this.model.root) {
await this.model.root.switchMode("edit");
} else {
console.error('Model or model root is not defined');
}
},

async saveButtonClicked(params = {}) {
if (originalSaveButtonClicked) {
await originalSaveButtonClicked.call(this, params);
}

if (!this.env.inDialog) {
await this.model.root.switchMode("readonly");
} else {
this.model.actionService.doAction({ type: 'ir.actions.act_window_close' });
}
},

async discard() {
if (originalDiscard) {
await originalDiscard.call(this);
}

if (!this.env.inDialog) {
await this.model.root.switchMode("readonly");
} else {
this.model.actionService.doAction({ type: 'ir.actions.act_window_close' });
}
},

async beforeLeave() {
if (this.model.root.isDirty) {
if (confirm("The changes you have made will save Automatically!")) {
await this.model.root.save();
return true;
} else {
return false;
}
}
return true;
}

})

<templates xml:space="preserve">

<t t-inherit="web.FormView" t-inherit-mode="extension">
<xpath expr="//t[@t-if='canCreate']" position="after">
<t t-if="!canEdit">
<button type="button" class="btn btn-outline-primary o_form_button_edit" t-on-click="edit" data-hotkey="a">Edit</button>
</t>
<div t-if="model.root.isInEdition" class="o_form_buttons_edit">
<button type="button" class="btn btn-primary o_form_button_save" t-on-click="saveButtonClicked" data-hotkey="s">
<i class="fa fa-cloud-upload fa-fw"></i>
</button>
<button type="button" class="btn btn-secondary o_form_button_cancel" t-on-click="discard" data-hotkey="j">
<i class="fa fa-undo fa-fw"></i>
</button>
</div>
</xpath>
</t>

</templates>
Avatar
Ignorer