From 9a9720ac14d3508e93339e351ba19de4b3ca2fd6 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 24 Aug 2015 18:05:26 +0200 Subject: [PATCH 01/14] [FIX] sale: in a SO line, changing uom qty must change uos qty This is a regression from rev. 1cedcf6abb433beb78675557fabd9ee6e49c504e Not updating the product uos qty on updating the uom qty is wrong, and it has multiple side-effect. The SO line margin not being correctly recomputed when changing the quantity is one of them. opw-647902 --- addons/sale/sale.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 0457abc0fa1..da75b51eba4 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1199,7 +1199,10 @@ class sale_order_line(osv.osv): else: result.update({'price_unit': price}) if context.get('uom_qty_change', False): - return {'value': {'price_unit': price}, 'domain': {}, 'warning': False} + values = {'price_unit': price} + if result.get('product_uos_qty'): + values['product_uos_qty'] = result['product_uos_qty'] + return {'value': values, 'domain': {}, 'warning': False} if warning_msgs: warning = { 'title': _('Configuration Error!'), From 802d1abe7a446e4034f0af74d023acdd4dd45324 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 24 Aug 2015 18:16:05 +0200 Subject: [PATCH 02/14] [FIX] account: invoice lines amounts must be rounded when converted to journal items This revision is related to cfbd086b09faa77f44505e1ba952841e77da6002. This is the same use case than above, but with a different currency than the one of the company, for the field `amount_currency` this time. Closes #8135 opw-647639 --- addons/account/account_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 1cd11d9fb11..116f5d2d684 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -739,7 +739,7 @@ class account_invoice(models.Model): if self.currency_id != company_currency: currency = self.currency_id.with_context(date=self.date_invoice or fields.Date.context_today(self)) line['currency_id'] = currency.id - line['amount_currency'] = line['price'] + line['amount_currency'] = currency.round(line['price']) line['price'] = currency.compute(line['price'], company_currency) else: line['currency_id'] = False From 2d3973481f6252797ca8f405fabca153e6ec040b Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 24 Aug 2015 18:27:02 +0200 Subject: [PATCH 03/14] [FIX] point_of_sale: Sales details products translations In the Sales Details report, the products were not translated in the user language. opw-647700 --- addons/point_of_sale/report/pos_details.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/report/pos_details.py b/addons/point_of_sale/report/pos_details.py index f430029ea2d..927d5a7611f 100644 --- a/addons/point_of_sale/report/pos_details.py +++ b/addons/point_of_sale/report/pos_details.py @@ -47,7 +47,7 @@ class pos_details(report_sxw.rml_parse): user_ids = form['user_ids'] or self._get_all_users() company_id = user_obj.browse(self.cr, self.uid, self.uid).company_id.id pos_ids = pos_obj.search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('user_id','in',user_ids),('state','in',['done','paid','invoiced']),('company_id','=',company_id)]) - for pos in pos_obj.browse(self.cr, self.uid, pos_ids): + for pos in pos_obj.browse(self.cr, self.uid, pos_ids, context=self.localcontext): for pol in pos.lines: result = { 'code': pol.product_id.default_code, From 1f57c9a5a662f4be41b1e08d9cd21061b1c59a64 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 24 Aug 2015 17:01:30 +0200 Subject: [PATCH 04/14] [FIX] website_mail: do not reveal full email address in contact name When subscribing a document, a partner is created based on the email address. Instead of using the email address as the name (which is a bit too spammer friendly), only keep the first part of the email address as a name. Following discussion https://www.odoo.com/groups/59/13640169 --- addons/website_mail/controllers/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/website_mail/controllers/main.py b/addons/website_mail/controllers/main.py index 18bddd09a58..092465850f0 100644 --- a/addons/website_mail/controllers/main.py +++ b/addons/website_mail/controllers/main.py @@ -46,7 +46,8 @@ class WebsiteMail(http.Controller): partner_ids = _object._find_partner_from_emails( cr, SUPERUSER_ID, _id, [email], context=context, check_followers=True) if not partner_ids or not partner_ids[0]: - partner_ids = [partner_obj.create(cr, SUPERUSER_ID, {'name': email, 'email': email}, context=context)] + name = email.split('@')[0] + partner_ids = [partner_obj.create(cr, SUPERUSER_ID, {'name': name, 'email': email}, context=context)] # add or remove follower if _message_is_follower: From 3e82c94d695327d5fa85cf6c9eca5039d7bc1bb6 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 20 Aug 2015 10:32:43 +0200 Subject: [PATCH 05/14] [FIX] point_of_sale,base: use context timezone for sequence Previously when replacing time related sequence in a prefix or suffix of a sequence, the timezone used for the time values would always be the server's timezone. With this fix, the context timezone is used if available (UTC is used otherwise). closes #8159 opw-646487 --- addons/point_of_sale/point_of_sale.py | 2 +- openerp/addons/base/ir/ir_sequence.py | 29 +++++++++++++-------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index cc51b8823ea..5ba591b39a7 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -425,7 +425,7 @@ class pos_session(osv.osv): bank_statement_ids.append(statement_id) values.update({ - 'name': self.pool['ir.sequence'].get(cr, uid, 'pos.session'), + 'name': self.pool['ir.sequence'].get(cr, uid, 'pos.session', context=context), 'statement_ids' : [(6, 0, bank_statement_ids)], 'config_id': config_id }) diff --git a/openerp/addons/base/ir/ir_sequence.py b/openerp/addons/base/ir/ir_sequence.py index 999f12a9d18..f93d7ba7eee 100644 --- a/openerp/addons/base/ir/ir_sequence.py +++ b/openerp/addons/base/ir/ir_sequence.py @@ -19,7 +19,9 @@ # ############################################################################## +from datetime import datetime import logging +import pytz import time import openerp @@ -218,21 +220,18 @@ class ir_sequence(openerp.osv.osv.osv): return s % d return '' - def _interpolation_dict(self): - t = time.localtime() # Actually, the server is always in UTC. - return { - 'year': time.strftime('%Y', t), - 'month': time.strftime('%m', t), - 'day': time.strftime('%d', t), - 'y': time.strftime('%y', t), - 'doy': time.strftime('%j', t), - 'woy': time.strftime('%W', t), - 'weekday': time.strftime('%w', t), - 'h24': time.strftime('%H', t), - 'h12': time.strftime('%I', t), - 'min': time.strftime('%M', t), - 'sec': time.strftime('%S', t), + def _interpolation_dict_context(self, context=None): + if context is None: + context = {} + t = datetime.now(pytz.timezone(context.get('tz') or 'UTC')) + sequences = { + 'year': '%Y', 'month': '%m', 'day': '%d', 'y': '%y', 'doy': '%j', 'woy': '%W', + 'weekday': '%w', 'h24': '%H', 'h12': '%I', 'min': '%M', 'sec': '%S' } + return {key: t.strftime(sequence) for key, sequence in sequences.iteritems()} + + def _interpolation_dict(self): + return self._interpolation_dict_context() def _next(self, cr, uid, ids, context=None): if not ids: @@ -252,7 +251,7 @@ class ir_sequence(openerp.osv.osv.osv): cr.execute("SELECT number_next FROM ir_sequence WHERE id=%s FOR UPDATE NOWAIT", (seq['id'],)) cr.execute("UPDATE ir_sequence SET number_next=number_next+number_increment WHERE id=%s ", (seq['id'],)) self.invalidate_cache(cr, uid, ['number_next'], [seq['id']], context=context) - d = self._interpolation_dict() + d = self._interpolation_dict_context(context=context) try: interpolated_prefix = self._interpolate(seq['prefix'], d) interpolated_suffix = self._interpolate(seq['suffix'], d) From 3b02e3d63dcb62ed24cdbbdb7bd06f67849e1a24 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 25 Aug 2015 14:52:20 +0200 Subject: [PATCH 06/14] [FIX] sale*: company tax filtering f26b94f had as goal to filter the taxes of the product according to the company when the sale.order was created/edited as SUPERUSER_ID (Who ignores the record rules). Unfortunetaly, to filter the taxes, it used the company of the customer, while it's actually the company of the order which should be used. Indeed, for instance, partners can be shared among all companies. It was way less simple to access the company of the sale.order, this parameter being not available in the on_change method signature. This is the easiest way to solve this issue without breaking the API / retro-compatibility. opw-647819 --- addons/sale/sale.py | 7 ++++--- addons/sale/sale_view.xml | 11 ++++++----- addons/sale_stock/sale_stock_view.xml | 10 +++++----- addons/website_quote/controllers/main.py | 2 +- .../website_quote/views/website_quotation_backend.xml | 2 +- addons/website_sale/models/sale_order.py | 2 +- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index da75b51eba4..a0ccaf86361 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1078,7 +1078,7 @@ class sale_order_line(osv.osv): date_order=order['date_order'], fiscal_position=order['fiscal_position'][0] if order['fiscal_position'] else False, flag=False, # Force name update - context=context + context=dict(context, company_id=values.get('company_id')) )['value'] if defaults.get('tax_id'): defaults['tax_id'] = [[6, 0, defaults['tax_id']]] @@ -1134,8 +1134,9 @@ class sale_order_line(osv.osv): # The superuser is used by website_sale in order to create a sale order. We need to make # sure we only select the taxes related to the company of the partner. This should only # apply if the partner is linked to a company. - if uid == SUPERUSER_ID and partner.company_id: - taxes = product_obj.taxes_id.filtered(lambda r: r.company_id == partner.company_id) + if uid == SUPERUSER_ID and context.get('company_id'): + print 'company_id found', context['company_id'] + taxes = product_obj.taxes_id.filtered(lambda r: r.company_id.id == context['company_id']) else: taxes = product_obj.taxes_id result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes) diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 7a0925e990a..93df0e5f714 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -123,17 +123,17 @@