From 066fbb66132724b23129071193785e33d0c2bdd9 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 29 Sep 2014 14:48:11 +0200 Subject: [PATCH 1/3] [FIX] account_anglo_saxon: price difference, discount and taxes When computing the price difference amount do not integrate the eventual discount and taxes included in the price. Otherwise the total of the generated accounting enty would be higher than the total of the invoice. opw 611350 --- addons/account_anglo_saxon/invoice.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/account_anglo_saxon/invoice.py b/addons/account_anglo_saxon/invoice.py index 8a816b0c962..ec455fc49d8 100644 --- a/addons/account_anglo_saxon/invoice.py +++ b/addons/account_anglo_saxon/invoice.py @@ -110,14 +110,18 @@ class account_invoice_line(osv.osv): if inv.currency_id.id != company_currency: standard_price = self.pool.get('res.currency').compute(cr, uid, company_currency, inv.currency_id.id, standard_price, context={'date': inv.date_invoice}) if standard_price != i_line.price_unit and line['price_unit'] == i_line.price_unit and acc: - price_diff = round(i_line.price_unit - standard_price, account_prec) - line.update({'price': round(standard_price * line['quantity'], account_prec)}) + # price with discount and without tax included + price_unit = self.pool['account.tax'].compute_all(cr, uid, line['taxes'], + i_line.price_unit * (1-(i_line.discount or 0.0)/100.0), line['quantity'])['total'] + price_line = round(standard_price * line['quantity'], account_prec) + price_diff = round(price_unit - price_line, account_prec) + line.update({'price': price_line}) diff_res.append({ 'type':'src', 'name': i_line.name[:64], - 'price_unit':price_diff, + 'price_unit': round(price_diff / line['quantity'], account_prec), 'quantity':line['quantity'], - 'price': round(price_diff * line['quantity'], account_prec), + 'price': price_diff, 'account_id':acc, 'product_id':line['product_id'], 'uos_id':line['uos_id'], From e11d44eab499a59e09aadcf170177bd5b18d5c2f Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 3 Oct 2014 15:12:04 +0200 Subject: [PATCH 2/3] [FIX] event: missing context This fixes some translation issues (templates not translated at event confirmation) --- addons/event/event.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/event/event.py b/addons/event/event.py index 937884fd087..f62551fb359 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -114,7 +114,7 @@ class event_event(osv.osv): reg_ids = register_pool.search(cr, uid, [ ('event_id', '=', self.event.id), ('state', 'not in', ['draft', 'cancel'])], context=context) - register_pool.mail_user_confirm(cr, uid, reg_ids) + register_pool.mail_user_confirm(cr, uid, reg_ids, context=context) return self.write(cr, uid, ids, {'state': 'confirm'}, context=context) def button_confirm(self, cr, uid, ids, context=None): @@ -165,7 +165,7 @@ class event_event(osv.osv): res = {} for event in self.browse(cr, uid, ids, context=context): res[event.id] = False - curr_reg_id = register_pool.search(cr, uid, [('user_id', '=', uid), ('event_id', '=' ,event.id)]) + curr_reg_id = register_pool.search(cr, uid, [('user_id', '=', uid), ('event_id', '=' ,event.id)], context=context) if curr_reg_id: for reg in register_pool.browse(cr, uid, curr_reg_id, context=context): if reg.state in ('open','done'): @@ -226,7 +226,7 @@ class event_event(osv.osv): curr_reg_ids = register_pool.search(cr, uid, [('user_id', '=', user.id), ('event_id', '=' , ids[0])]) #the subscription is done with SUPERUSER_ID because in case we share the kanban view, we want anyone to be able to subscribe if not curr_reg_ids: - curr_reg_ids = [register_pool.create(cr, SUPERUSER_ID, {'event_id': ids[0] ,'email': user.email, 'name':user.name, 'user_id': user.id, 'nb_register': num_of_seats})] + curr_reg_ids = [register_pool.create(cr, SUPERUSER_ID, {'event_id': ids[0] ,'email': user.email, 'name':user.name, 'user_id': user.id, 'nb_register': num_of_seats}, context=context)] else: register_pool.write(cr, uid, curr_reg_ids, {'nb_register': num_of_seats}, context=context) return register_pool.confirm_registration(cr, SUPERUSER_ID, curr_reg_ids, context=context) @@ -234,7 +234,7 @@ class event_event(osv.osv): def unsubscribe_to_event(self, cr, uid, ids, context=None): register_pool = self.pool.get('event.registration') #the unsubscription is done with SUPERUSER_ID because in case we share the kanban view, we want anyone to be able to unsubscribe - curr_reg_ids = register_pool.search(cr, SUPERUSER_ID, [('user_id', '=', uid), ('event_id', '=', ids[0])]) + curr_reg_ids = register_pool.search(cr, SUPERUSER_ID, [('user_id', '=', uid), ('event_id', '=', ids[0])], context=context) return register_pool.button_reg_cancel(cr, SUPERUSER_ID, curr_reg_ids, context=context) def _check_closing_date(self, cr, uid, ids, context=None): @@ -250,7 +250,7 @@ class event_event(osv.osv): def onchange_event_type(self, cr, uid, ids, type_event, context=None): values = {} if type_event: - type_info = self.pool.get('event.type').browse(cr,uid,type_event,context) + type_info = self.pool.get('event.type').browse(cr,uid,type_event,context, context=context) dic ={ 'reply_to': type_info.default_reply_to, 'email_registration_id': type_info.default_email_registration.id, From b3485fb59c5b488e887feb4b356341be86e9db82 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 3 Oct 2014 15:15:12 +0200 Subject: [PATCH 3/3] [FIX] event: double context --- addons/event/event.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/event/event.py b/addons/event/event.py index f62551fb359..5027cfaf717 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -250,7 +250,7 @@ class event_event(osv.osv): def onchange_event_type(self, cr, uid, ids, type_event, context=None): values = {} if type_event: - type_info = self.pool.get('event.type').browse(cr,uid,type_event,context, context=context) + type_info = self.pool.get('event.type').browse(cr,uid,type_event, context=context) dic ={ 'reply_to': type_info.default_reply_to, 'email_registration_id': type_info.default_email_registration.id,