[IMP] qweb: t-field-options is a python dict, safe_eval for compile template, not need to eval in field methods

This commit is contained in:
Christophe Matthieu
2016-06-14 13:12:14 +02:00
parent f4f396c4ab
commit d9efca0908
22 changed files with 105 additions and 113 deletions
+3 -3
View File
@@ -85,7 +85,7 @@
</td>
<td class="text-right">
<span t-field="l.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</tbody>
@@ -97,7 +97,7 @@
<tr class="border-black">
<td><strong>Subtotal</strong></td>
<td class="text-right">
<span t-field="o.amount_untaxed" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
<span t-field="o.amount_untaxed" t-field-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
<t t-foreach="o._get_tax_amount_by_group()" t-as="amount_by_group">
@@ -111,7 +111,7 @@
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-field="o.amount_total" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
<span t-field="o.amount_total" t-field-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</table>
@@ -18,7 +18,7 @@
<img t-att-src="'data:image/png;base64,%s' % o.event_id.organizer_id.company_id.logo_web" style="max-height:1cm; max-width:4cm;"/>
</span>
<h5 t-field="o.event_id.name"/>
<h5>( <i class="fa fa-clock-o"></i> <span itemprop="startDate" t-field="o.event_id.date_begin" t-field-options='{"hide_seconds":"True"}'> </span> <i>to</i> <span itemprop="endDate" t-field="o.event_id.date_end" t-field-options='{"hide_seconds":"True"}'> </span> )</h5>
<h5>( <i class="fa fa-clock-o"></i> <span itemprop="startDate" t-field="o.event_id.date_begin" t-field-options='{"hide_seconds": True}'> </span> <i>to</i> <span itemprop="endDate" t-field="o.event_id.date_end" t-field-options='{"hide_seconds": True}'> </span> )</h5>
</div>
<div class="row">
<div class="col-xs-12 text-center" id="o_event_name">
@@ -69,7 +69,7 @@
</div>
</span>
<h4 t-field="event.name"/>
<h5>( <i class="fa fa-clock-o"></i> <span itemprop="startDate" t-field="event.date_begin" t-field-options='{"hide_seconds":"True"}'> </span> <i>to</i> <span itemprop="endDate" t-field="event.date_end" t-field-options='{"hide_seconds":"True"}'> </span> )</h5>
<h5>( <i class="fa fa-clock-o"></i> <span itemprop="startDate" t-field="event.date_begin" t-field-options='{"hide_seconds": True}'> </span> <i>to</i> <span itemprop="endDate" t-field="event.date_end" t-field-options='{"hide_seconds": True}'> </span> )</h5>
</div>
</div>
<div class="row" t-ignore="true">
+2 -2
View File
@@ -55,7 +55,7 @@
</td>
<td>
<span t-field="line.unit_amount"
t-field-options='{"widget": "monetary", "display_currency":"line.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": line.currency_id}'/>
</td>
<td class="text-center">
<span t-field="line.quantity"/>
@@ -75,7 +75,7 @@
</td>
<td class="text-right">
<span t-field="line.total_amount"
t-field-options='{"widget": "monetary", "display_currency":"line.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": line.currency_id}'/>
</td>
</tr>
</t>
@@ -51,7 +51,7 @@
</td>
<td class="text-right">
<span t-field="line.price"
t-field-options='{"widget": "monetary", "display_currency": "user.company_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": user.company_id.currency_id}'/>
</td>
</tr>
</t>
@@ -88,7 +88,7 @@
</td>
<td class="text-right">
<span t-field="line.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": o.pricelist_id.currency_id}'/>
</td>
</t>
</tr>
@@ -112,7 +112,7 @@
</td>
<td class="text-right">
<span t-field="fees.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": o.pricelist_id.currency_id}'/>
</td>
</t>
</tr>
@@ -127,21 +127,21 @@
<td><strong>Total Without Taxes</strong></td>
<td class="text-right">
<span t-field="o.amount_untaxed"
t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": o.pricelist_id.currency_id}'/>
</td>
</tr>
<tr>
<td>Taxes</td>
<td class="text-right">
<span t-field="o.amount_tax"
t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": o.pricelist_id.currency_id}'/>
</td>
</tr>
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-field="o.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": o.pricelist_id.currency_id}'/>
</td>
</tr>
</table>
@@ -34,11 +34,11 @@
</div>
<div class="col-xs-3">
<strong>Starting Balance</strong>:<br/>
<span t-field="o.balance_start" t-field-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/>
<span t-field="o.balance_start" t-field-options='{"widget": "monetary", "display_currency": res_company.currency_id}'/>
</div>
<div class="col-xs-3">
<strong>Ending Balance</strong>:<br/>
<span t-field="o.balance_end_real" t-field-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/>
<span t-field="o.balance_end_real" t-field-options='{"widget": "monetary", "display_currency": res_company.currency_id}'/>
</div>
</div>
@@ -56,7 +56,7 @@
<td><span t-esc="line.partner_id.name"/></td>
<td class="text-right">
<span t-field="line.amount"
t-field-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": res_company.currency_id}'/>
</td>
</tr>
</tbody>
@@ -67,7 +67,7 @@
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right"><span t-esc="sum([line.amount for line in o.line_ids])" t-esc-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/></td>
<td class="text-right"><span t-esc="format(sum([line.amount for line in o.line_ids]), 'monetary', res_company.currency_id)"/></td>
</tr>
</table>
</div>
@@ -76,7 +76,7 @@
</td>
<td class="text-right">
<span t-field="line.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</tbody>
@@ -89,21 +89,21 @@
<td><strong>Total Without Taxes</strong></td>
<td class="text-right">
<span t-field="o.amount_untaxed"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
<tr>
<td>Taxes</td>
<td class="text-right">
<span t-field="o.amount_tax"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-field="o.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</table>
@@ -67,7 +67,7 @@
<td t-if="display_discount" groups="sale.group_discount_per_so_line"><span t-field="l.discount"/></td>
<td class="text-right">
<span t-field="l.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</tbody>
@@ -79,19 +79,19 @@
<tr class="border-black">
<td><strong>Total Without Taxes</strong></td>
<td class="text-right">
<span t-field="o.amount_untaxed" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
<span t-field="o.amount_untaxed" t-field-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
<tr>
<td>Taxes</td>
<td class="text-right">
<span t-field="o.amount_tax" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
<span t-field="o.amount_tax" t-field-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-field="o.amount_total" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
<span t-field="o.amount_total" t-field-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</table>
@@ -112,7 +112,7 @@
<td><span t-field="t.name"/></td>
<td class="text-right">
<span t-field="t.amount"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</tbody>
@@ -48,7 +48,7 @@
</td>
<td class="text-right">
<span t-field="l.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</t>
+3 -3
View File
@@ -97,7 +97,7 @@
</td>
<td class="text-right">
<span t-field="l.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
</td>
</tr>
</t>
@@ -128,7 +128,7 @@
<td><strong>Total Without Taxes</strong></td>
<td class="text-right">
<span t-field="doc.amount_untaxed"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
</td>
</tr>
<t t-foreach="doc._get_tax_amount_by_group()" t-as="amount_by_group">
@@ -143,7 +143,7 @@
<td><strong>Total</strong></td>
<td class="text-right">
<span t-field="doc.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
</td>
</tr>
</table>
+1 -2
View File
@@ -2,7 +2,6 @@
from openerp.addons.web.http import request
from openerp.osv import orm
import ast
from openerp.addons.base.ir.ir_qweb import utils
class QWeb(orm.AbstractModel):
@@ -29,7 +28,7 @@ class QWeb(orm.AbstractModel):
]
def _website_build_attribute(self, tagName, name, value, qwebcontext):
context = qwebcontext.context or {}
context = qwebcontext.env.context or {}
if not context.get('rendering_bundle'):
if name == self.URL_ATTRS.get(tagName) and qwebcontext.get('url_for'):
return qwebcontext.get('url_for')(value or '')
@@ -40,13 +40,13 @@
<t t-if="(ticket.price-ticket.price_reduce) &gt; 1">
<del class="text-danger mr4" style="white-space: nowrap;" t-field="ticket.price" t-field-options='{
"widget": "monetary",
"from_currency": "website.currency_id",
"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"
"from_currency": website.currency_id,
"display_currency": user_id.partner_id.property_product_pricelist.currency_id
}'/>
</t>
<span t-field="ticket.price_reduce" t-field-options='{
"widget": "monetary",
"display_currency": "website.pricelist_id.currency_id"
"display_currency": website.pricelist_id.currency_id
}'/>
<span itemprop="price" style="display:none;" t-esc="ticket.price"/>
<span itemprop="priceCurrency" style="display:none;" t-esc="website.pricelist_id.currency_id.name"/>
@@ -248,7 +248,7 @@
<b>Date</b><br/>
<span t-field="track.date" t-field-options='{"hide_seconds":"True"}'/><br/>
<b>Duration</b><br/>
<span t-field="track.duration" t-field-options="{&quot;widget&quot;: &quot;duration&quot;, &quot;unit&quot;: &quot;hour&quot;}"/><br/>
<span t-field="track.duration" t-field-options='{"widget": "duration", "unit": "hour"}'/><br/>
<b>Location</b><br/>
<span t-field="track.location_id"/><br/>
</div>
@@ -91,7 +91,7 @@
<span class="label label-default"><i class="fa fa-fw fa-clock-o"/> Expired</span>
</t>
</td>
<td><span t-field="quotation.amount_total" t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'/>
<td><span t-field="quotation.amount_total" t-field-options='{"widget": "monetary", "display_currency": quotation.pricelist_id.currency_id}'/>
</td>
</tr>
</t>
@@ -136,7 +136,7 @@
<span class="label label-default"><i class="fa fa-fw fa-check"/> Done</span>
</t>
</td>
<td><span t-field="order.amount_total" t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/></td>
<td><span t-field="order.amount_total" t-field-options='{"widget": "monetary", "display_currency": order.pricelist_id.currency_id}'/></td>
</tr>
</t>
</table>
@@ -186,7 +186,7 @@
<td>
<a t-if="invoice.state == 'open'" t-attf-href="/website_payment/pay?reference=#{invoice.number}&amp;amount=#{invoice.residual}&amp;currency_id=#{invoice.currency_id.id}&amp;country_id=#{invoice.partner_id.country_id.id}" alt="Pay Now" class="btn btn-xs btn-primary"><i class="fa fa-arrow-circle-right"/> Pay Now</a>
</td>
<td><span t-field="invoice.residual" t-field-options='{"widget": "monetary", "display_currency": "invoice.currency_id"}'/></td>
<td><span t-field="invoice.residual" t-field-options='{"widget": "monetary", "display_currency": invoice.currency_id}'/></td>
</tr>
</t>
</table>
@@ -319,7 +319,7 @@
<span t-esc="ol.product_id.name"/>
</div>
<div class="col-md-2 text-right">
<span t-field="ol.price_unit" t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/>
<span t-field="ol.price_unit" t-field-options='{"widget": "monetary", "display_currency": order.pricelist_id.currency_id}'/>
</div>
<div class="col-md-2 text-right">
<t t-if="ol._name == 'sale.order.line'">
@@ -330,7 +330,7 @@
</t>
</div>
<div class="col-md-2 text-right">
<span t-field="ol.price_subtotal" t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/>
<span t-field="ol.price_subtotal" t-field-options='{"widget": "monetary", "display_currency": order.pricelist_id.currency_id}'/>
</div>
</div>
</t>
@@ -350,7 +350,7 @@
Untaxed Amount:
</div>
<div class="col-md-2 text-right">
<span t-field="order.amount_untaxed" t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/>
<span t-field="order.amount_untaxed" t-field-options='{"widget": "monetary", "display_currency": order.pricelist_id.currency_id}'/>
</div>
</div>
<div class="row">
@@ -358,7 +358,7 @@
Taxes:
</div>
<div class="col-md-2 text-right">
<span t-field="order.amount_tax" t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/>
<span t-field="order.amount_tax" t-field-options='{"widget": "monetary", "display_currency": order.pricelist_id.currency_id}'/>
</div>
</div>
<div class="row">
@@ -366,7 +366,7 @@
<strong>Total:</strong>
</div>
<div class="col-md-2 text-right">
<strong><span t-field="order.amount_total" t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/></strong>
<strong><span t-field="order.amount_total" t-field-options='{"widget": "monetary", "display_currency": order.pricelist_id.currency_id}'/></strong>
</div>
</div>
</div>
@@ -38,7 +38,7 @@
<td>
<strong class="text-right">
<div t-field="option.price_unit"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'
t-field-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
t-att-style="option.discount and 'text-decoration: line-through' or None"
t-att-class="option.discount and 'text-danger' or None"/>
<div t-if="option.discount">
@@ -61,7 +61,7 @@
</td>
<td class="text-right">
<div t-field="line.price_unit"
t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'
t-field-options='{"widget": "monetary", "display_currency": quotation.pricelist_id.currency_id}'
t-att-style="line.discount and 'text-decoration: line-through' or None"
t-att-class="(line.discount and 'text-danger' or '') + ' text-right'"/>
<!-- TODO: apply monetary widget formating -->
@@ -72,7 +72,7 @@
<td>
<div class="text-right"
t-field="line.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": quotation.pricelist_id.currency_id}'/>
</td>
<td class="text-center">
<a t-attf-href="./update_line/#{ line.id }/?order_id=#{ quotation.id }&amp;unlink=True&amp;token=#{ quotation.access_token }" class="mb8 js_update_line_json hidden-print" t-if="line.option_line_id">
@@ -99,7 +99,7 @@
<td></td><td></td><td></td><td></td>
<td class="text-right"><strong>Subtotal:</strong></td>
<td class="text-right">
<strong data-id="total_amount" t-field="quotation.amount_untaxed" t-field-options='{"widget": "monetary","display_currency": "quotation.pricelist_id.currency_id"}'/>
<strong data-id="total_amount" t-field="quotation.amount_untaxed" t-field-options='{"widget": "monetary","display_currency": quotation.pricelist_id.currency_id}'/>
</td>
<td></td>
</tr>
@@ -108,7 +108,7 @@
<td></td><td></td><td></td><td></td>
<td class="text-right">Taxes:</td>
<td class="text-right">
<span data-id="total_amount" t-field="quotation.amount_tax" t-field-options='{"widget": "monetary","display_currency": "quotation.pricelist_id.currency_id"}'/>
<span data-id="total_amount" t-field="quotation.amount_tax" t-field-options='{"widget": "monetary","display_currency": quotation.pricelist_id.currency_id}'/>
</td>
<td></td>
</tr>
@@ -116,7 +116,7 @@
<td></td><td></td><td></td><td></td>
<td class="text-right"><strong>Total:</strong></td>
<td class="text-right">
<strong data-id="total_amount" t-field="quotation.amount_total" t-field-options='{"widget": "monetary","display_currency": "quotation.pricelist_id.currency_id"}'/>
<strong data-id="total_amount" t-field="quotation.amount_total" t-field-options='{"widget": "monetary","display_currency": quotation.pricelist_id.currency_id}'/>
</td>
<td></td>
</tr>
@@ -220,22 +220,22 @@
<p class="text-muted mb8">Your advantage:</p>
<t t-if="quotation.amount_untaxed == quotation.amount_total">
<strong t-field="quotation.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": quotation.pricelist_id.currency_id}'/>
<strong t-field="quotation.amount_undiscounted"
t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'
t-field-options='{"widget": "monetary", "display_currency": quotation.pricelist_id.currency_id}'
style="text-decoration: line-through"
class="text-danger"/>
</t>
<t t-if="quotation.amount_untaxed != quotation.amount_total">
<strong t-field="quotation.amount_untaxed"
t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": quotation.pricelist_id.currency_id}'/>
<strong t-field="quotation.amount_undiscounted"
t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'
t-field-options='{"widget": "monetary", "display_currency": quotation.pricelist_id.currency_id}'
style="text-decoration: line-through"
class="text-danger"/>
<br />
(<span t-field="quotation.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'/> Incl. tax)
t-field-options='{"widget": "monetary", "display_currency": quotation.pricelist_id.currency_id}'/> Incl. tax)
</t>
</div>
</div>
@@ -292,7 +292,7 @@
<span>I agree that by signing this proposal, I
accept it on the behalf of </span><b t-field="quotation.company_id"/><span>, for an amount of </span>
<b data-id="total_amount" t-field="quotation.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": quotation.pricelist_id.currency_id}'/>
<span>with payment terms: </span><b t-field="quotation.payment_term_id"/>.
</p>
<div id="signer" class="form-group">
@@ -319,7 +319,7 @@
<span>I agree that by paying this proposal, I
accept it on the behalf of </span><b t-field="quotation.company_id"/><span>, for an amount of </span>
<b data-id="total_amount" t-field="quotation.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": quotation.pricelist_id.currency_id}'/>
<span>with payment terms: </span><b t-field="quotation.payment_term_id"/>.
</p>
</div>
@@ -587,7 +587,7 @@
<td>
<strong class="text-right">
<div t-field="option.price_unit"
t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'
t-field-options='{"widget": "monetary", "display_currency": quotation.pricelist_id.currency_id}'
t-att-style="option.discount and 'text-decoration: line-through' or None"
t-att-class="option.discount and 'text-danger' or None"/>
<div t-if="option.discount">
@@ -699,7 +699,7 @@
<span class="label label-default"><i class="fa fa-fw fa-clock-o"/> Expired</span>
</t>
</td>
<td><span t-field="quotation.amount_total" t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'/>
<td><span t-field="quotation.amount_total" t-field-options='{"widget": "monetary", "display_currency": quotation.pricelist_id.currency_id}'/>
</td>
</tr>
</t>
@@ -35,7 +35,7 @@
</td>
<td class="text-right">
<span t-field="doc.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
</td>
</tr>
</tbody>
+32 -32
View File
@@ -78,7 +78,7 @@
</div>
<div class="oe_product_image">
<a itemprop="url" t-att-href="keep('/shop/product/%s' % slug(product), page=(pager['page']['num'] if pager['page']['num']>1 else None))">
<span itemprop="image" t-field="product.image" t-field-options='{"widget": "image" #{None if product_image_big else ", \"resize\": \"300x300\""}}' t-att-alt="product.name"/>
<span itemprop="image" t-field="product.image" t-field-options='{"widget": "image", "resize": None if product_image_big else "300x300"}' t-att-alt="product.name"/>
</a>
</div>
<t t-if="show_publish">
@@ -97,13 +97,13 @@
<t t-if="(compute_currency(product.lst_price) - product.price) &gt; 0.1">
<del class="text-danger mr8" style="white-space: nowrap;" t-field="product.lst_price" t-field-options='{
"widget": "monetary",
"from_currency": "product.currency_id",
"display_currency": "website.currency_id"
"from_currency": product.currency_id,
"display_currency": website.currency_id
}'/>
</t>
<span t-field="product.price" style="white-space: nowrap;" t-field-options='{
"widget": "monetary",
"display_currency": "website.currency_id"
"display_currency": website.currency_id
}'>
</span>
<span itemprop="price" style="display:none;" t-esc="product.price"/>
@@ -437,14 +437,14 @@
t-field="product.lst_price"
t-field-options='{
"widget": "monetary",
"from_currency": "product.currency_id",
"display_currency": "website.currency_id"
"from_currency": product.currency_id,
"display_currency": website.currency_id
}'/>
<b class="oe_price" style="white-space: nowrap;"
t-field="product.price"
t-field-options='{
"widget": "monetary",
"display_currency": "website.currency_id"
"display_currency": website.currency_id
}'/>
<span itemprop="price" style="display:none;" t-esc="product.price"/>
<span itemprop="priceCurrency" style="display:none;" t-esc="website.currency_id.name"/>
@@ -453,7 +453,7 @@
<span t-field="product.lst_price"
t-field-options='{
"widget": "monetary",
"display_currency": "product.currency_id"
"display_currency": product.currency_id
}'/>
</h4>
<h4 class="hidden oe_not_available bg-warning">Product not available</h4>
@@ -473,8 +473,8 @@
<span class="badge" t-if="variant_id.price_extra">
<t t-esc="variant_id.price_extra > 0 and '+' or ''"/><span t-field="variant_id.price_extra" style="white-space: nowrap;" t-field-options='{
"widget": "monetary",
"from_currency": "product.currency_id",
"display_currency": "website.currency_id"
"from_currency": product.currency_id,
"display_currency": website.currency_id
}'/>
</span>
</label>
@@ -498,8 +498,8 @@
<span t-if="value_id.price_extra">
<t t-esc="value_id.price_extra > 0 and '+' or ''"/><span t-field="value_id.price_extra" style="white-space: nowrap;" t-field-options='{
"widget": "monetary",
"from_currency": "product.currency_id",
"display_currency": "website.currency_id"
"from_currency": product.currency_id,
"display_currency": website.currency_id
}'/>
</span>
</option>
@@ -518,8 +518,8 @@
<span class="badge" t-if="value_id.price_extra">
<t t-esc="value_id.price_extra > 0 and '+' or ''"/><span t-field="value_id.price_extra" style="white-space: nowrap;" t-field-options='{
"widget": "monetary",
"from_currency": "product.currency_id",
"display_currency": "website.currency_id"
"from_currency": product.currency_id,
"display_currency": website.currency_id
}'/>
</span>
</label>
@@ -793,12 +793,12 @@
<del t-attf-class="text-danger #{'' if line.product_id.lst_price &gt; line.discounted_price else 'hidden'}" style="text-decoration: line-through; white-space: nowrap;"
t-field="line.product_id.lst_price" t-field-options='{
"widget": "monetary",
"from_currency": "line.company_id.currency_id",
"display_currency": "website.currency_id"
"from_currency": line.company_id.currency_id,
"display_currency": website.currency_id
}'/>
<span t-field="line.discounted_price" style="white-space: nowrap;" t-field-options='{
"widget": "monetary",
"display_currency": "website.currency_id"
"display_currency": website.currency_id
}'/>
</td>
</tr>
@@ -914,13 +914,13 @@
<del class="text-danger mr8" style="white-space: nowrap;"
t-field="product.lst_price" t-field-options='{
"widget": "monetary",
"from_currency": "product.currency_id",
"display_currency": "website.currency_id"
"from_currency": product.currency_id,
"display_currency": website.currency_id
}'/>
</t>
<span t-field="product.price" style="white-space: nowrap;" t-field-options='{
"widget": "monetary",
"display_currency": "website.currency_id"
"display_currency": website.currency_id
}'/>
</td>
<td class="text-center">
@@ -1169,8 +1169,8 @@
<td class="text-center">
<span t-field="line.price_unit" style="white-space: nowrap;" t-field-options='{
"widget": "monetary",
"from_currency": "website_sale_order.pricelist_id.currency_id",
"display_currency": "website.currency_id"
"from_currency": website_sale_order.pricelist_id.currency_id,
"display_currency": website.currency_id
}'/>
</td>
</tr>
@@ -1310,13 +1310,13 @@
<td>
<strong class="text-right">
<div t-field="line.price_unit"
t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": order.pricelist_id.currency_id}'/>
</strong>
</td>
<td>
<div class="text-right"
t-field="line.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": order.pricelist_id.currency_id}'/>
</td>
</tr>
<tr>
@@ -1324,7 +1324,7 @@
<td class="text-right"><strong>Total:</strong></td>
<td class="text-right">
<strong t-field="order.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": order.pricelist_id.currency_id}'/>
</td>
</tr>
</tbody>
@@ -1341,7 +1341,7 @@
<td class="text-right" width="100"><strong>Total:</strong></td>
<td class="text-right" width="100">
<strong t-field="order.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/>
t-field-options='{"widget": "monetary", "display_currency": order.pricelist_id.currency_id}'/>
</td>
</tr>
</tbody>
@@ -1410,8 +1410,8 @@
<span class="col-xs-6 text-left text-muted">
<span t-field="website_sale_order.amount_untaxed" style="white-space: nowrap;" t-field-options='{
"widget": "monetary",
"from_currency": "website_sale_order.pricelist_id.currency_id",
"display_currency": "website.currency_id"
"from_currency": website_sale_order.pricelist_id.currency_id,
"display_currency": website.currency_id
}'/>
</span>
</div>
@@ -1420,8 +1420,8 @@
<span class="col-xs-6 text-left text-muted">
<span t-field="website_sale_order.amount_tax" style="white-space: nowrap;" t-field-options='{
"widget": "monetary",
"from_currency": "website_sale_order.pricelist_id.currency_id",
"display_currency": "website.currency_id"
"from_currency": website_sale_order.pricelist_id.currency_id,
"display_currency": website.currency_id
}'/>
</span>
</div>
@@ -1430,8 +1430,8 @@
<span class="col-xs-6 text-left h4" style="white-space: nowrap;">
<span t-field="website_sale_order.amount_total" style="white-space: nowrap;" t-field-options='{
"widget": "monetary",
"from_currency": "website_sale_order.pricelist_id.currency_id",
"display_currency": "website.currency_id"
"from_currency": website_sale_order.pricelist_id.currency_id,
"display_currency": website.currency_id
}'/>
</span>
</div>
@@ -9,8 +9,8 @@
<span class="col-xs-6 text-left text-muted">
<span t-field="website_sale_order.amount_delivery" style="white-space: nowrap;" t-field-options='{
"widget": "monetary",
"from_currency": "website_sale_order.currency_id",
"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"
"from_currency": website_sale_order.currency_id,
"display_currency": user_id.partner_id.property_product_pricelist.currency_id
}'/>
</span>
</div>
@@ -38,8 +38,8 @@
<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"
"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>
@@ -59,15 +59,15 @@
t-field="product.lst_price"
t-field-options='{
"widget": "monetary",
"from_currency": "product.currency_id",
"display_currency": "website.currency_id"
"from_currency": product.currency_id,
"display_currency": website.currency_id
}'/>
<span class="oe_price" style="white-space: nowrap;"
t-att-data-product-id="product.id"
t-field="product.price"
t-field-options='{
"widget": "monetary",
"display_currency": "website.currency_id"
"display_currency": website.currency_id
}'/>
</td>
<td>
@@ -106,14 +106,14 @@
t-field="product.lst_price"
t-field-options='{
"widget": "monetary",
"from_currency": "product.currency_id",
"display_currency": "website.currency_id"
"from_currency": product.currency_id,
"display_currency": website.currency_id
}'/><br/>
<span class="oe_price" style="white-space: nowrap;"
t-field="product.price"
t-field-options='{
"widget": "monetary",
"display_currency": "website.currency_id"
"display_currency": website.currency_id
}'/>
<p class="css_not_available_msg bg-danger" style="position:absolute; padding: 15px;">Product not available</p>
</td>
+3 -9
View File
@@ -6,7 +6,7 @@ from PIL import Image
from cStringIO import StringIO
import babel
from openerp.tools import html_escape as escape, posix_to_ldml
from .utils import QWebContext, eval_expr, unicodifier
from .utils import QWebContext, unicodifier
import logging
_logger = logging.getLogger(__name__)
@@ -308,7 +308,7 @@ class MonetaryConverter(models.AbstractModel):
display_currency = record[field.currency_field]
#otherwise fall back to old method
if not display_currency:
display_currency = self.display_currency(options['display_currency'], qwebcontext)
display_currency = options['display_currency']
# lang.format mandates a sprintf-style format. These formats are non-
# minimal (they have a default fixed precision instead), and
@@ -320,8 +320,7 @@ class MonetaryConverter(models.AbstractModel):
from_amount = record[field_name]
if options.get('from_currency'):
from_currency = self.display_currency(options['from_currency'], qwebcontext)
from_amount = from_currency.compute(from_amount, display_currency)
from_amount = options['from_currency'].compute(from_amount, display_currency)
lang = self.user_lang()
formatted_amount = lang.format(fmt, display_currency.round(from_amount),
@@ -339,11 +338,6 @@ class MonetaryConverter(models.AbstractModel):
symbol=display_currency.symbol,
)
@api.model
def display_currency(self, currency, qwebcontext):
return eval_expr(currency, qwebcontext)
TIMEDELTA_UNITS = (
('year', 3600 * 24 * 365),
('month', 3600 * 24 * 30),
+1 -2
View File
@@ -866,7 +866,7 @@ class QWeb(models.AbstractModel):
ast.Str(expression),
ast.Name(id='default_content', ctx=ast.Load()),
ast.Str(node_name),
options and utils.compile_format(options) or ast.Name(id='None', ctx=ast.Load()),
options and utils.compile_expr(options) or ast.Dict(keys=[], values=[]),
ast.Name(id='qwebcontext', ctx=ast.Load()),
],
keywords=[], starargs=None, kwargs=None
@@ -949,7 +949,6 @@ class QWeb(models.AbstractModel):
return (files, remains)
def _get_field(self, record, field_name, expression, default_content, tagName, options, qwebcontext):
options = options and json.loads(options) or {}
field = record._fields[field_name]
field_type = options.get('widget', field.type)