odoo电子商务网格视图和列表视图切换而不是替换

时间:2016-12-04 16:27:00

标签: openerp odoo-website

在odoo网站中,我们可以将视图从网格切换到产品列表的列表视图。但是,当从自定义部分打开视图时,它将替换产品网格视图。以下是将网格视图替换为列表视图的行:

    <xpath expr="//div[@id='products_grid']//table" position="replace">
        <t t-foreach="products" t-as="product">
            <div class="oe_product oe_list oe_product_cart" t-att-data-publish="product.website_published and 'on' or 'off'">
                <t t-call="website_sale.products_item">
                    <t t-set="show_publish" t-value="True" />
                </t>
            </div>
        </t>
    </xpath>

如何为产品网格和列表设置两个视图,以便我们可以切换视图?

我可以继承视图并将它们放在自定义模块的新模板上。喜欢:

                        <!--- THE GRID VIEW -->                            
                         <table width="100%">
                            <tbody>
                                <tr t-ignore="true">
                                    <td t-foreach="range(0,rows)" t-as="row" t-attf-width="#{100/rows}%"></td>
                                </tr>
                                <tr t-foreach="bins" t-as="tr_product">
                                    <t t-foreach="tr_product" t-as="td_product">
                                        <t t-if="td_product">
                                            <t t-set="product" t-value="td_product['product']" />
                                            <td t-att-colspan="td_product['x'] != 1 and td_product['x']" t-att-rowspan="td_product['y'] != 1 and td_product['y']" t-attf-class="oe_product oe_grid oe-height-#{td_product['y']*2} #{ td_product['class'] }">
                                                <div class="oe_product_cart" t-att-data-publish="product.website_published and 'on' or 'off'">
                                                    <t t-set="product_image_big" t-value="td_product['x']+td_product['y'] &gt; 2" />
                                                    <t t-call="website_sale.products_item" />
                                                </div>
                                            </td>
                                        </t>
                                        <td t-if="not td_product" class="oe-height-2" />
                                    </t>
                                </tr>
                            </tbody>
                        </table>
                      <!--- THE LIST VIEW -->
                      <t t-foreach="products" t-as="product">
                         <div class="oe_product oe_list oe_product_cart" t-att-data-publish="product.website_published and 'on' or 'off'">
                            <t t-call="website_sale.products_item">
                               <t t-set="show_publish" t-value="True" />
                            </t>
                         </div>
                      </t>

现在,我该如何为此实现切换视图?

0 个答案:

没有答案