Odoo Help

0

Delivery costs on shopping cart

By
Laura
on 4/20/16, 8:04 AM 883 views

Hi!!Is it possible change or duplicate the delivery costs on payment to shopping cart? 
I show you an image of example (made it on Photoshop). -->
The code of each part is:
- Delivery (without tax) - (website_sale_delivery.cart_delivery):

<data name="Delivery Costs" inherit_id="website_sale.total">

          <xpath expr="//tr[@id='order_total_taxes']" position="after">

                <tr class="text-muted" id="order_delivery">

                       <td>

                             <abbr title="Shipping">Envío sin IVA:</abbr>

                      </td>

                    <td class="text-right">

                            <span t-field="website_sale_order.amount_delivery" t-field-options="{ "widget": "monetary", "display_currency": "website.pricelist_id.currency_id" }"/>

                    </td>

              </tr>

        </xpath>

</data>


- Country + State/Province (website_sale.checkout):

<form action="/shop/confirm_order" method="post">

    <div t-attf-class="form-group #{error.get('country_id') and 'has-error' or ''} col-lg-6">

        <label class="control-label" for="country_id">Country *</label>

            <select name="country_id" class="form-control">

                <option value="">Country...</option>

                  <t t-foreach="countries or []" t-as="country">

                        <option t-att-value="country.id" t-att-selected="country.id == checkout.get('country_id')">

                        <t t-esc="country.name"/>

                        </option>

                </t>

        </select>

    </div>

    <div t-attf-class="form-group #{error.get('state_id') and 'has-error' or ''} col-lg-6">

        <label class="control-label" for="state_id" style="font-weight: normal">

            <strong>State / Province *</strong>

        </label>

        <select name="state_id" class="form-control">

            <option value="">select...</option>

            <t t-foreach="states or []" t-as="state">

                <option t-att-value="state.id" style="display:none;" t-att-data-country_id="state.country_id.id" t-att-selected="state.id == checkout.get('state_id')">

                <t t-esc="state.name"/>

            </option>

        </t>

        </select>

    </div>

</form>


- Choose your delivery method (website_sale_delivery.payment_delivery):

<data name="Delivery Costs" inherit_id="website_sale.payment">

    <xpath expr="//div[@id='payment_method']" position="before">

        <div t-if="deliveries" class="row" id="delivery_carrier">

            <div class="col-lg-5 col-sm-6">

                <h4>Choose your Delivery Method</h4>

                    <ul class="list-unstyled">

                        <li t-foreach="deliveries" t-as="delivery">

                            <t t-if="delivery.available">

                                <label>

                                    <input t-att-value="delivery.id" type="radio" name="delivery_type" t-att-checked="order.carrier_id and order.carrier_id.id == delivery.id and 'checked' or False"/>

                                    <span t-field="delivery.name"/>

                                    <span class="badge" t-field="delivery.price" t-field-options="{ "widget": "monetary", "display_currency": "website.pricelist_id.currency_id" }"/>

                            </label>

                        </t>

                    </li>

                </ul>

            </div>

        </div>

    </xpath>

</data>


Regards 

0
F. P.
On 8/1/17, 10:54 AM

yes it is possible. you need make modifications in website_sale_delivery model too. in order to get it there.


class sale_order(osv.Model):
_inherit = 'sale.order'

amount_delivery_total = fields.Float(
compute='_compute_amount_delivery_total',
digits=decimal_precision.get_precision('Account'),
string='Delivery amount with taxes',
store=False,
help="The delivery amount with taxes",
track_visibility='always'
)

@api.depends('order_line', 'order_line.price_subtotal')
def _compute_amount_delivery_total(self):
"""compute Function for amount_delivery_total."""
for rec in self:
line_amount = sum([line.price_subtotal + self._amount_line_tax(line) for line in
rec.order_line if line.is_delivery])
currency = rec.pricelist_id.currency_id
rec.amount_delivery_total = currency.round(line_amount)


<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<template id="website_sale_delivery.cart_delivery" name="custom.delivery_costs" inherit_id="website_sale.total">
<xpath expr="//tr[@id='order_total_taxes']" position="before">
<tr id="order_delivery" class="text-muted">
<!--td><abbr title="Delivery will be updated after choosing a new delivery method">Delivery:</abbr></td-->
<td><abbr>Delivery:</abbr></td>
<td class="text-right">
<span class="nowrap" t-field="website_sale_order.amount_delivery_total" t-field-options='{
"widget": "monetary",
"display_currency": "website_sale_order.currency_id"
}'/>
</td>
</tr>
</xpath>
</template>

<template id="website_sale_delivery.payment_delivery" name="custom.delivery_carriers" inherit_id="website_sale.payment">
<xpath expr="//div[@id='payment_method']" position="before">
<div t-if="deliveries" class="row" id="delivery_carrier" t-att-style="'display:none;' if len(deliveries) &lt;= 1 else ''">
<div class="col-lg-5 col-sm-6">
<h4>Choose your Delivery Method</h4>
<ul class="list-unstyled">
<li t-foreach="deliveries" t-as="delivery">
<t t-if="delivery.available">
<label>
<input t-att-value="delivery.id" type="radio" name="delivery_type" t-att-checked="order.carrier_id and order.carrier_id.id == delivery.id and 'checked' or False"/>
<span t-field="delivery.name"/>
<span class="badge" t-field="delivery.price" t-field-options='{ "widget": "monetary", "from_currency": "delivery.product_id.company_id.currency_id", "display_currency": "website_sale_order.currency_id" }'/>
<div t-field="delivery.website_description" class="text-muted"/>
</label>
</t>
</li>
</ul>
</div>
</div>
</xpath>
</template>

</data>
</openerp>



I might have slightly different xml layout than original template but you can make it work.



0
Laura
On 4/25/16, 2:28 AM

Link of image:  https://www.odoo.com/web/content/2273149?download=true 

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 4/20/16, 8:04 AM
Seen: 883 times
Last updated: 8/1/17, 10:54 AM