[ADD] conversion back from HTML to monetary field

bzr revid: xmo@openerp.com-20131011142528-oruyq6r7vf962lqn
This commit is contained in:
Xavier Morel
2013-10-11 16:25:28 +02:00
parent 8a10e6a688
commit 3e349a2bf7
+2 -20
View File
@@ -179,26 +179,8 @@ class Image(orm.AbstractModel):
return out.getvalue().encode('base64')
class Monetary(orm.AbstractModel):
"""
The website's monetary field/widget can become website-aware, and thus
should be able to use a pricelist somehow available through the session?
Why not directly the qweb context. There's also a method stored in
the ecommerce controller in website_sale, would that one be a good/better
idea? => just eval some string and hope that's a pricelist?
Either way, it also gets the ability to fetch the "company" pricelist
via website.get_current().company_id (or 'res_company' in the qweb context)
The widget then needs to call (ir.currency).compute(from_currency,
to_currency, value) to convert the company's to the user's during display
and the other way around during parsing
"""
_name = 'website.qweb.field.monetary'
_inherit = ['website.qweb.field', 'ir.qweb.field.monetary']
def source_currency(self, cr, uid, options):
assert 'source_currency' not in options,\
u"The source currency is automatically defined by the website" \
u" and must not be provided"
return self.pool['website'].get_current().company_id.currency_id
def from_html(self, cr, uid, model, column, element, context=None):
return float(element.find('span').text)