跳至內容
選單
此問題已被標幟
3 回覆
9803 瀏覽次數

I need to modify the method called by the "delete" button, so I would like to know:

  • how to load the buttons menu of the sidebar?

  • how to modify the name that puts the items?

  • how to configure which methods of the python class to call?

頭像
捨棄
作者

That is, how can I customize 'options.actions' in the .py file of the class?

File : web/static/src/js/chrome/sidebar.js

odoo.define('web.Sidebar', function (require) {

"use strict";

var Context = require('web.Context');

var core = require('web.core');

var pyeval = require('web.pyeval');

var Widget = require('web.Widget');

var QWeb = core.qweb;

var _t = core._t;

var Sidebar = Widget.extend({

events: {

"click .dropdown-menu li a": "_onDropdownClicked"

},

init: function (parent, options) {

this._super.apply(this, arguments);

this.options = _.defaults(options || {},

{ 'editable': true });

this.env = options.env;

this.sections = options.sections || [

{name: 'print', label: _t('Print')},

{name: 'other', label: _t('Action')},

];

this.items = options.items || {

print: [],

other: [],

};

if (options.actions) {

this._addToolbarActions(options.actions);

}

},

作者

file: web/static/src/js/views/form/form_controller.js

FORM_CONTROLLER:

renderSidebar: function ($node) {

if (!this.sidebar && this.hasSidebar) {

var otherItems = [];

if (this.is_action_enabled('delete')) {

otherItems.push({

label: _t('Delete'),

callback: this._onDeleteRecord.bind(this),

});

}

if (this.is_action_enabled('create') && this.is_action_enabled('duplicate')) {

otherItems.push({

label: _t('Duplicate'),

callback: this._onDuplicateRecord.bind(this),

});

}

this.sidebar = new Sidebar(this, {

editable: this.is_action_enabled('edit'),

viewType: 'form',

env: {

context: this.model.get(this.handle).getContext(),

activeIds: this.getSelectedIds(),

model: this.modelName,

},

actions: _.extend(this.toolbarActions, {other: otherItems}),

});

this.sidebar.appendTo($node);

// Show or hide the sidebar according to the view mode

this._updateSidebar();

}

},

作者 最佳答案

Solution: add "ir.actions.server"

Former:



    
< record id = "action_model_done_something" model = "ir.actions.server" >
    < field name = "name" > Label </ field > 
< field name = "model_id" ref = "model_name_class" />
< field name = "binding_model_id" ref = "module.model_name_class" />
< field name = "state" > code </ field >
< field name = "code" >
for rec in records: rec.action_feedback (feedback = 'Closed automatically in batch')
</ field >
</record >
    
頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
5月 21
2682
0
3月 15
3106
0
3月 15
4069
1
3月 15
5540
1
9月 24
1157