Odoo POS创建一个下拉列表 [英] Odoo POS create a dropdown list

查看:354
本文介绍了Odoo POS创建一个下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我在POS合作伙伴屏幕中创建下拉列表. 我在pos.xml文件中添加了此内容,但下拉列表为空.谢谢

Can anyone help me with creating a dropdown list in the POS partner screen. I added this in the pos.xml file, but the dropdown is empty. Thanks

<div class='client-detail'>
     <span class='label'>CustomerGroup</span>
     <select class='*what to place here?*' name='group_id'>
         <option value=''>None</option>
         <t t-foreach='*what to place here?*' t-as='group'>
             <option t-att-value='group.id' t-att-selected="partner_group_id ? ((group.id === partner.group_id[0]) ? true : undefined) : undefined"> 
                 <t t-esc='group.name'/>
             </option>
         </t>
     </select>
</div>

我已从国家/地区"下拉列表中复制了此文件.

I've copied this from the country dropdown list.

推荐答案

example.js

example.js

您可以根据需要设置self.groups和self.partners的值.

you can set values of self.groups and self.partners as per your requirement.

 render_function : function(){
    var self = this;
    var template_window =  $(QWeb.render("template_name", {
            groups : self.groups,
            partners : self.partners,
            }));
    template_window.appendTo(this.$el);
  },

example.xml

example.xml

   <div class='client-detail'>
         <span class='label'>CustomerGroup</span>
         <select class='group_class' name='group_id'>
             <option value=''></option>
             <t t-foreach='groups' t-as='group'>
                 <option t-att-value='group.id' t-att-selected="partner_group_id ? ((group.id === partner.group_id[0]) ? true : undefined) : undefined"> 
                     <t t-esc='group.name'/>
                 </option>
             </t>
         </select>
    </div>

您可以在"group_class"的位置设置任何类名,并且可以使用该类名从gui到js代码中获取选定的值.

you can set any class name at place of "group_class" and you can use this class name to get selected values from gui to your js code.

t-foreach ='groups',这里的groups是您在渲染模板时从js传递的字典键的名称.

t-foreach='groups' here groups is name of dictionary key that you passed from js at time of rendering the template.

这篇关于Odoo POS创建一个下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆