odoo/addons/ecommerce/views/ecommerce.xml

160 lines
7.1 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Layout add nav and footer -->
<record id="layout_ecommerce" model="ir.ui.view">
<field name="name">layout_ecommerce</field>
<field name="inherit_id" ref="website.layout"/>
<field name="arch" type="xml">
<data>
<xpath expr="(//header//li)[last()]" position="after">
<li class="pull-right"><a href="/shop/my_cart">My cart</a></li>
<li class="pull-right"><a href="/shop">Shop</a></li>
</xpath>
<xpath expr="//footer/div/div/div[3]" position="inside">
SHOP Footer
</xpath>
</data>
</field>
</record>
<!-- Page Shop -->
<record id="page" model="ir.ui.view">
<field name="name">page</field>
<field name="type">qweb</field>
<field name="arch" type="xml">
<t t-call="website.layout">
<t t-set="title">Shop - <t t-raw="title">Categories</t></t>
<div class="container oe_ecommerce">
<div class="row">
<div class="span4">
<ul class="nav nav-list">
<t t-foreach="categories" t-as="category">
<t t-call="ecommerce.categories_recursive"/>
</t>
</ul>
</div>
<div class="span8">
<t t-raw="shop_content">
<t t-foreach="products" t-as="product">
<t t-set="quantity" t-value="product.id in cart and cart[product.id]['quantity'] or 0"/>
<t t-call="ecommerce.products"/>
</t>
</t>
</div>
</div>
</div>
</t>
</field>
</record>
<!-- List of categories -->
<record id="categories_recursive" model="ir.ui.view">
<field name="name">categories_recursive</field>
<field name="type">qweb</field>
<field name="arch" type="xml">
<li t-att-class="category.id == current_category and 'active' or ''">
<a t-att-href="'/shop/category/%%s' %% category.id"><t t-esc="category.name"/></a>
<ul t-if="category.child_id" class="nav nav-list">
<t t-foreach="category.child_id" t-as="category">
<t t-call="ecommerce.categories_recursive"/>
</t>
</ul>
</li>
</field>
</record>
<!-- Product list -->
<record id="products" model="ir.ui.view">
<field name="name">products</field>
<field name="type">qweb</field>
<field name="arch" type="xml">
<div class="media">
<div class="pull-left" style="width:64px; height:64px;">
<img style="max-width:64px; max-height:64px; margin:auto;" class="media-object" t-att-src="'data:image/png;base64,' + product.image"/>
</div>
<div class="media-body">
<div class="oe_button_cart">
<button t-if="my_cart" t-att-class="'btn btn-inverse %%s' %% (not quantity and 'oe_hidden' or '')" t-att-data-id="product.id">Remove one</button>
<button t-att-class="'btn %%s' %% (quantity and 'btn-success' or 'btn-primary')" t-att-data-id="product.id">
<span class="oe_txt_empty">Add to cart</span>
<span class="oe_txt">Add one (<span class="oe_quantity"><t t-esc="quantity"/></span> in my cart)</span>
</button>
</div>
<a t-att-href="'/shop/product/%%s' %% product.id"><h4 class="media-heading"><t t-esc="product.name"/></h4></a>
<t t-esc="product.description_sale"/>
<div><t t-esc="product.list_price"/></div>
</div>
</div>
</field>
</record>
<!-- product -->
<record id="product" model="ir.ui.view">
<field name="name">product</field>
<field name="type">qweb</field>
<field name="arch" type="xml">
<t t-call="ecommerce.page">
<t t-set="title">Product</t>
<t t-set="shop_content">
<h1><t t-esc="product.name"/></h1>
<img style="max-width:128px; max-height:128px;" t-att-src="'data:image/png;base64,' + product.image"/>
<t t-esc="product.description_sale"/>
<div><t t-esc="product.list_price"/></div>
<h1>Giga poulet !</h1>
</t>
</t>
</field>
</record>
<!-- Page Shop my cart -->
<record id="my_cart" model="ir.ui.view">
<field name="name">my_cart</field>
<field name="type">qweb</field>
<field name="arch" type="xml">
<t t-call="ecommerce.page">
<t t-set="title">My cart</t>
<t t-set="shop_content">
<t t-foreach="order.order_line" t-as="line">
<t t-set="product" t-value="line.product_id"/>
<t t-set="quantity" t-value="int(line.product_uom_qty)"/>
<t t-call="ecommerce.products"/>
</t>
<div class="media well">
<h1>
<a href="/shop/customer"><button class="btn btn-success">Confirm my order</button></a>
Total: <span class="oe_total"><t t-esc="order.amount_total"/></span>
</h1>
</div>
</t>
</t>
</field>
</record>
<!-- Page confirm my cart -->
<record id="customer" model="ir.ui.view">
<field name="name">customer</field>
<field name="type">qweb</field>
<field name="arch" type="xml">
<t t-call="ecommerce.page">
<t t-set="title">Your information</t>
<t t-set="shop_content">
<form action="/shop/confirm_cart">
<input name="name"/>
<input name="firstname"/>
<button class="btn btn-success">Next</button>
</form>
</t>
</t>
</field>
</record>
</data>
</openerp>