简体   繁体   English

Odoo POS 创建下拉列表

[英]Odoo POS create a dropdown list

Can anyone help me with creating a dropdown list in the POS partner screen.任何人都可以帮助我在 POS 合作伙伴屏幕中创建一个下拉列表。 I added this in the pos.xml file, but the dropdown is empty.我在 pos.xml 文件中添加了这个,但下拉列表是空的。 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例子.js

you can set values of self.groups and self.partners as per your requirement.您可以根据需要设置 self.groups 和 self.partners 的值。

 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例子.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>

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.您可以在“group_class”的位置设置任何类名,并且您可以使用这个类名将选定的值从 gui 获取到您的 js 代码。

t-foreach='groups' here groups is name of dictionary key that you passed from js at time of rendering the template. t-foreach='groups' 此处的组是您在渲染模板时从 js 传递的字典键的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM