Odoo POS create a dropdown list

六眼飞鱼酱① 提交于 2019-12-11 00:59:44

问题


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.


回答1:


example.js

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

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

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



来源:https://stackoverflow.com/questions/35890929/odoo-pos-create-a-dropdown-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!