Hi, I have form view with many2many field account_ids with its records presented in tree view.
Inside tree view, there is field and button. I want to click on button and copy value of child_name to parent_name. It should works like copy and paste or like default parameter in modules. No saving.
<form>
<sheet>
<field name="parent_name"/>
<notebook>
<page>
<field name="account_ids">
<tree>
<field name="child_name"/>
<button icon="fa-upload" name="button"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
The problem is that clicking on a button always causes the client to issue a write or create call before running the method.
So, I think only way to do that is to use Javascript/jQuery.
odoo.define('budget.button.copy_name', function (require) {
"use strict";
var FieldRegistry = require('web.field_registry');
// extend web.relational_fields???
var FieldMany2Many = require('web.relational_fields').FieldMany2Many;
// extend web.FormController???
var FormController = require('web.FormController');
// extend web.ListController
var FormController = require('web.ListController');
// what JS/jQuery code to put here? something like this?
var CopyFieldMany2Many = FieldMany2Many.extend({
_onButtonClicked: function (ev) {
// what to put here?
}
});
FieldRegistry.add('copy_name', CopyFieldMany2Many);
});
How should view look like? Is...
<button icon="fa-upload" name="button"/>
...good?
Or it should be like this?
<field name="account_ids" widget="copy_name">
Or maybe should I do this in OWL Framework?
Big thanks for helping me :)