[Odoo 13] How to copy value from many2many child field to ...

文章推薦指數: 80 %
投票人數:10人

So, I think only way to do that is to use Javascript/jQuery. odoo.define('budget.button.copy_name' ... what JS/jQuery code to put here? something like this? 幫助 Dismiss Odooistheworld'seasiestall-in-onemanagementsoftware.Itincludeshundredsofbusinessapps: 客戶關係管理 e-Commerce 會計 庫存管理 PoS Projectmanagement MRP Takethetour 所有論壇 主題 人 標籤 徽章 關於 來去: 疑問 所有主題 人 標籤 徽章 關於 0 編輯 關閉 刪除 標記 編輯 關閉 刪除 標記 DanielRybak 184月2020 退訂 訂閱 Thanksforyoursubscription! javascriptjquerymany2manyOdoo13owl Hi,Ihaveformviewwithmany2manyfield account_ids withitsrecordspresentedintreeview.Insidetreeview,thereisfieldandbutton.Iwanttoclickonbuttonandcopyvalueof child_name to parent_name.Itshouldworkslikecopyandpasteorlikedefaultparameterinmodules.Nosaving. 

                                                                                                                                                                                                                                                                     
Theproblemisthat clickingonabutton alwayscausestheclienttoissueawriteorcreatecallbeforerunningthemethod.So,IthinkonlywaytodothatistouseJavascript/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);});Howshouldviewlooklike?Is...                                      ...good?Oritshouldbelikethis?                        OrmaybeshouldIdothisinOWLFramework?Bigthanksforhelpingme:)  評論 分享 貼子評論 取消 1答案 1 DanielRybak 194月2020 最佳答案 Withthehelpofmybrotherwe'vemanagedtodothat.Thisisthesolution:ChangesinXML:...WholeJSfile:odoo.define('budget.button.copy_name',function(require){  "usestrict";  varFormController=require('web.FormController');  varFormView=require('web.FormView');  varviewRegistry=require('web.view_registry');  varCopyFormController=FormController.extend({},{    _onButtonClicked:function(ev){      if(ev.data.attrs.button_class==='button_copy_name'){                //putconcatenatedstrings intoinput                //withoutchange()youwon'tsaveinputedvalue                //focus()istoputcursorintoinputfield(i.e.toedittextimmediately)               $("input[name='name']").val(`${ev.data.record.data.code}${ev.data.record.data.name}`).change().focus();       }else{        returnthis._super.apply(this,arguments)      }           }  });  varCopyFormView=FormView.extend({    config:_.extend({},FormView.prototype.config,{      Controller:CopyFormController,    }),  });  viewRegistry.add('copy_name',CopyFormView);}); 評論 分享 貼子評論 取消 OdooExperienceonYouTube 1.Usethelivechattoaskyourquestions. 2.Theoperatoranswerswithinafewminutes. Watchnow


請為這篇文章評分?