openerp7 widget 之 ChangePassword
来源:互联网 发布:扫码枪软件下载 编辑:程序博客网 时间:2024/06/15 23:58
instance.web.client_actions.add("change_password", "instance.web.ChangePassword");
有个动作叫做change_password,把它的请求最终(在客户端)给instance.web.ChangePassword"给处理了。
1. 看看后台py代码:
\addons\base\res\res_users.py (481~486)
def preference_change_password(self, cr, uid, ids, context=None): return { 'type': 'ir.actions.client', 'tag': 'change_password', 'target': 'new', }
类型是 ir.actions.client
2. qweb
xml: \addons\web\static\src\xml\base.xml (333~363)
js: \addons\web\static\src\js\chrome.js (819~852)
instance.web.ChangePassword = instance.web.Widget.extend({ template: "ChangePassword", start: function() { var self = this; this.getParent().dialog_title = _t("Change Password"); var $button = self.$el.find('.oe_form_button'); $button.appendTo(this.getParent().$buttons); $button.eq(2).click(function(){ self.getParent().close(); }) $button.eq(0).click(function(){ self.rpc("/web/session/change_password",{ 'fields': $("form[name=change_password_form]").serializeArray() }).done(function(result) { if (result.error) { self.display_error(result); return; } else { instance.webclient.on_logout(); } }); }) }, display_error: function (error) { return instance.web.dialog($('<div>'), { modal: true, title: error.title, buttons: [ {text: _t("Ok"), click: function() { $(this).dialog("close"); }} ] }).html(error.error); },})instance.web.client_actions.add("change_password", "instance.web.ChangePassword");
<t t-name="ChangePassword"> <form name="change_password_form" method="POST"> <div class="oe_form"> <table align="center"> <tr> <td class="oe_form_group_cell oe_form_group_cell_label"><label for="old_pwd" class="oe_form_label">Old Password:</label></td> <td class="oe_form_group_cell"><input type="password" name="old_pwd" minlength="1" autofocus="autofocus"/></td> </tr> <tr> <td class="oe_form_group_cell oe_form_group_cell_label"><label for="new_password" class="oe_form_label">New Password:</label></td> <td class="oe_form_group_cell"><input type="password" name="new_password" minlength="1"/></td> </tr> <tr> <td class="oe_form_group_cell oe_form_group_cell_label"><label for="confirm_pwd" class="oe_form_label">Confirm New Password:</label></td> <td class="oe_form_group_cell"><input type="password" name="confirm_pwd" minlength="1"/></td> </tr> <tr> <td colspan="2" align="right"> <button class='oe_button oe_form_button'>Change Password</button> <span class="oe_fade oe_form_button"> or </span> <button type="button" class="oe_button oe_form_button_cancel oe_form_button oe_link" href="javascript:void(0)"><span>Cancel</span></button> </td> </tr> </table> </div> </form></t>
4. widget代码分析:
5. 细节
1). serializeArray
The serializeArray() method creates an array of objects (name and value) by serializing form values
将表单的input元素转为为{'name':input标签的name, 'value':input标签的value)
2).$button.appendTo(this.getParent().$buttons); 此处,讲按钮添加到form的$buttons里面,其原始html为:
"<span class="oe_dialog_custom_buttons"></span>" 此处用法不明。
3). rpc 调用路线:
widget -> instance.web.Controller(.rpc) -> instance.web.Session(.rpc) -> instance.web.JsonRPC( rpc) -> $.ajax(ajax)
ajax 结构
作者:深圳-Tommy
邮箱:lion_awake@163.com
有问题可以和我讨论,转载请注明出处,谢谢!
- openerp7 widget 之 ChangePassword
- changePassword
- OpenERP7.0之缺陷
- changePassword.jsp
- Meteor changePassword
- 探秘widget之widget背后的故事
- 探秘widget之widget背后的故事
- Android widget 之RemoteView
- Android widget 之RemoteView
- android widget之TextView
- android widget 之EditText
- android widget 之CheckBox
- Android之Widget
- Android widget 之RemoteView
- android--widget之menu
- Android widget 之RemoteView
- Yii之widget
- android之widget
- HDOJ 1556( 绝对原创且通俗的讲解 )
- 当键盘弹起的时候,屏幕适配键盘高度的方法
- HibernateTemplate() 获取最大记录数/记录总数/总数
- linux下编译libuv库
- vc链接静态库的时候要注意的问题
- openerp7 widget 之 ChangePassword
- 四大牛人看外国文献的方法
- Android学习——异常(1)
- GCD 之一: Dispatch Queue
- Map遍历四种方法
- 余凯在清华的讲座笔记
- 图片解析
- php进制转换
- 运行和学习高通提供的一些例子