summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-12-01 14:39:25 +0100
committerChristophe Simonis <chs@odoo.com>2016-12-01 14:39:25 +0100
commit97af2325cd802911e3f5851ea3dd4e4aac0ebd76 (patch)
tree9f079946d6ba4da3dfa40fa16dea37ed155f5a06 /addons
parentb3944ed0a08904eb4c2198c760dc7a6b7dcc59dd (diff)
parent0105cbbcf9754fee3ec349a9e0bcb028d59e914f (diff)
[MERGE] forward port branch 8.0 up to 0105cbb
Diffstat (limited to 'addons')
-rw-r--r--addons/membership/membership.py9
-rw-r--r--addons/purchase/purchase_data.yml4
-rw-r--r--addons/website/models/res_config.py2
-rw-r--r--addons/website/models/website.py2
-rw-r--r--addons/website_sale/data/demo.xml2
-rw-r--r--addons/website_sale/static/src/js/website_sale.js47
-rw-r--r--addons/website_sale/views/templates.xml6
7 files changed, 57 insertions, 15 deletions
diff --git a/addons/membership/membership.py b/addons/membership/membership.py
index c5e39f6da47..d61ca5ba34a 100644
--- a/addons/membership/membership.py
+++ b/addons/membership/membership.py
@@ -476,6 +476,15 @@ class Invoice(osv.osv):
'''Invoice'''
_inherit = 'account.invoice'
+ def action_cancel_draft(self, cr, uid, ids, context=None):
+ member_line_obj = self.pool.get('membership.membership_line')
+ for invoice in self.browse(cr, uid, ids, context=context):
+ mlines = member_line_obj.search(cr, uid,
+ [('account_invoice_line', 'in',
+ [l.id for l in invoice.invoice_line])])
+ member_line_obj.write(cr, uid, mlines, {'date_cancel': False}, context=context)
+ return super(Invoice, self).action_cancel_draft(cr, uid, ids, context=context)
+
def action_cancel(self, cr, uid, ids, context=None):
'''Create a 'date_cancel' on the membership_line object'''
member_line_obj = self.pool.get('membership.membership_line')
diff --git a/addons/purchase/purchase_data.yml b/addons/purchase/purchase_data.yml
index 92a88bc0c09..1133dfc3f37 100644
--- a/addons/purchase/purchase_data.yml
+++ b/addons/purchase/purchase_data.yml
@@ -1,8 +1,4 @@
-
- !python {model: ir.values}: |
- whr = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.warehouse0'), context=context)
- self.set_default(cr, uid, 'purchase.order', 'picking_type_id', whr.in_type_id.id, for_all_users=True, company_id=True, condition=False)
--
!python {model: stock.warehouse}: |
#enable purchase on main warehouse
main_warehouse = self.browse(cr, uid, ref('stock.warehouse0'), context=context)
diff --git a/addons/website/models/res_config.py b/addons/website/models/res_config.py
index 940b9a558e1..4ef59b43be3 100644
--- a/addons/website/models/res_config.py
+++ b/addons/website/models/res_config.py
@@ -10,7 +10,7 @@ class website_config_settings(osv.osv_memory):
'website_name': fields.related('website_id', 'name', type="char", string="Website Name"),
'language_ids': fields.related('website_id', 'language_ids', type='many2many', relation='res.lang', string='Languages'),
- 'default_lang_id': fields.related('website_id', 'default_lang_id', type='many2one', relation='res.lang', string='Default language'),
+ 'default_lang_id': fields.related('website_id', 'default_lang_id', type='many2one', relation='res.lang', string='Default language', required=True),
'default_lang_code': fields.related('website_id', 'default_lang_code', type="char", string="Default language code"),
'google_analytics_key': fields.related('website_id', 'google_analytics_key', type="char", string='Google Analytics Key'),
diff --git a/addons/website/models/website.py b/addons/website/models/website.py
index 2b37569a134..b05a65c1d8a 100644
--- a/addons/website/models/website.py
+++ b/addons/website/models/website.py
@@ -160,7 +160,7 @@ class website(osv.osv):
'domain': fields.char('Website Domain'),
'company_id': fields.many2one('res.company', string="Company"),
'language_ids': fields.many2many('res.lang', 'website_lang_rel', 'website_id', 'lang_id', 'Languages'),
- 'default_lang_id': fields.many2one('res.lang', string="Default language"),
+ 'default_lang_id': fields.many2one('res.lang', string="Default language", required=True),
'default_lang_code': fields.related('default_lang_id', 'code', type="char", string="Default language code", store=True),
'social_twitter': fields.char('Twitter Account'),
'social_facebook': fields.char('Facebook Account'),
diff --git a/addons/website_sale/data/demo.xml b/addons/website_sale/data/demo.xml
index 4cbf7ef6f38..985d767ea53 100644
--- a/addons/website_sale/data/demo.xml
+++ b/addons/website_sale/data/demo.xml
@@ -171,7 +171,7 @@
Capacity: 16GB
Connectivity: Wifi
Beautiful 7.9-inch display
-Over 375,000 apps3
+Over 375,000 apps
Ultrafast wireless
iOS7
</field>
diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js
index 0c51bd80e9f..7145cb1925d 100644
--- a/addons/website_sale/static/src/js/website_sale.js
+++ b/addons/website_sale/static/src/js/website_sale.js
@@ -77,13 +77,13 @@ $('.oe_website_sale').each(function () {
'line_id': line_id})
.then(function (res) {
//basic case
- $dom.find('span.oe_currency_value').last().text(res[product_id].toFixed(2));
+ $dom.find('span.oe_currency_value').last().text(price_to_str(res[product_id]));
$dom.find('.text-danger').toggle(res[product_id]<default_price && (default_price-res[product_id] > default_price/100));
//optional case
$dom_optional.each(function(){
var id = $(this).find('span[data-product-id]').data('product-id');
var price = parseFloat($(this).find(".text-danger > span.oe_currency_value").text());
- $(this).find("span.oe_currency_value").last().text(res[id].toFixed(2));
+ $(this).find("span.oe_currency_value").last().text(price_to_str(res[id]));
$(this).find('.text-danger').toggle(res[id]<price && (price-res[id]>price/100));
});
openerp.jsonRpc("/shop/cart/update_json", 'call', {
@@ -166,10 +166,47 @@ $('.oe_website_sale').each(function () {
$('.css_attribute_color:has(input:checked)').addClass("active");
});
+ // Copy from core.js that is not available in front end.
+ function intersperse(str, indices, separator) {
+ separator = separator || '';
+ var result = [], last = str.length;
+
+ for(var i=0; i<indices.length; ++i) {
+ var section = indices[i];
+ if (section === -1 || last <= 0) { break; }
+ else if(section === 0 && i === 0) { break; }
+ else if (section === 0) { section = indices[--i]; }
+ result.push(str.substring(last-section, last));
+ last -= section;
+ }
+ var s = str.substring(0, last);
+ if (s) { result.push(s); }
+ return result.reverse().join(separator);
+ }
+ function insert_thousand_seps(num) {
+ var l10n = openerp._t.database.parameters;
+ var negative = num[0] === '-';
+ num = (negative ? num.slice(1) : num);
+
+ return (negative ? '-' : '') + intersperse(
+ num, l10n.grouping, l10n.thousands_sep);
+ }
+
function price_to_str(price) {
- price = Math.round(price * 100) / 100;
- var dec = Math.round((price % 1) * 100);
- return price + (dec ? '' : '.0') + (dec%10 ? '' : '0');
+ var l10n = openerp._t.database.parameters;
+ var precision = 2;
+ if ($(".decimal_precision").length) {
+ var dec_precision = $(".decimal_precision").first().data('precision');
+ //MAth.log10 is not implemented in phantomJS
+ dec_precision = Math.round(Math.log(1/parseFloat(dec_precision))/Math.log(10));
+ if (!isNaN(dec_precision)) {
+ precision = dec_precision;
+ }
+ }
+ var formatted = _.str.sprintf('%.' + precision + 'f', price).split('.');
+ formatted[0] = insert_thousand_seps(formatted[0]);
+ var ret = formatted.join(l10n.decimal_point);
+ return ret;
}
$(oe_website_sale).on('change', 'input.js_product_change', function (ev) {
diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml
index c2680b309ae..474a21d5eef 100644
--- a/addons/website_sale/views/templates.xml
+++ b/addons/website_sale/views/templates.xml
@@ -97,7 +97,7 @@
}'>
</span>
<span itemprop="price" style="display:none;" t-esc="product.price"/>
- <span itemprop="priceCurrency" style="display:none;" t-esc="user_id.partner_id.property_product_pricelist.currency_id.name"/>
+ <span itemprop="priceCurrency" style="display:none;" t-esc="user_id.partner_id.property_product_pricelist.currency_id.name" class='decimal_precision' t-att-data-precision="website.pricelist_id.currency_id.rounding"/>
</b>
</div>
</section>
@@ -380,7 +380,7 @@
"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"
}'/>
<span itemprop="price" style="display:none;" t-esc="product.price"/>
- <span itemprop="priceCurrency" style="display:none;" t-esc="user_id.partner_id.property_product_pricelist.currency_id.name"/>
+ <span itemprop="priceCurrency" style="display:none;" t-esc="user_id.partner_id.property_product_pricelist.currency_id.name" class='decimal_precision' t-att-data-precision="website.pricelist_id.currency_id.rounding"/>
</h4>
<h4 class="css_non_editable_mode_hidden">
<span t-field="product.lst_price"
@@ -599,7 +599,7 @@
<thead>
<tr>
<th colspan="2" width="100">Product</th>
- <th width="100">Price</th>
+ <th width="100" class='decimal_precision' t-att-data-precision="website_sale_order.pricelist_id.currency_id.rounding">Price</th>
<th width="120">Quantity</th>
</tr>
</thead>