diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 72fea7d94ee..a269ae43b2c 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1380,6 +1380,7 @@ class account_voucher(osv.osv): move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') for voucher in self.browse(cr, uid, ids, context=context): + local_context = dict(context, force_company=voucher.journal_id.company_id.id) if voucher.move_id: continue company_currency = self._get_company_currency(cr, uid, voucher.id, context) @@ -1394,7 +1395,7 @@ class account_voucher(osv.osv): # Get the name of the account_move just created name = move_pool.browse(cr, uid, move_id, context=context).name # Create the first line of the voucher - move_line_id = move_line_pool.create(cr, uid, self.first_move_line_get(cr,uid,voucher.id, move_id, company_currency, current_currency, context), context) + move_line_id = move_line_pool.create(cr, uid, self.first_move_line_get(cr,uid,voucher.id, move_id, company_currency, current_currency, local_context), local_context) move_line_brw = move_line_pool.browse(cr, uid, move_line_id, context=context) line_total = move_line_brw.debit - move_line_brw.credit rec_list_ids = [] @@ -1406,9 +1407,9 @@ class account_voucher(osv.osv): line_total, rec_list_ids = self.voucher_move_line_create(cr, uid, voucher.id, line_total, move_id, company_currency, current_currency, context) # Create the writeoff line if needed - ml_writeoff = self.writeoff_move_line_get(cr, uid, voucher.id, line_total, move_id, name, company_currency, current_currency, context) + ml_writeoff = self.writeoff_move_line_get(cr, uid, voucher.id, line_total, move_id, name, company_currency, current_currency, local_context) if ml_writeoff: - move_line_pool.create(cr, uid, ml_writeoff, context) + move_line_pool.create(cr, uid, ml_writeoff, local_context) # We post the voucher. self.write(cr, uid, [voucher.id], { 'move_id': move_id, diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 805bfce4515..0c077807a6e 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -448,11 +448,12 @@ class pos_session(osv.osv): wf_service = netsvc.LocalService("workflow") for session in self.browse(cr, uid, ids, context=context): + local_context = dict(context or {}, force_company=session.config_id.journal_id.company_id.id) order_ids = [order.id for order in session.order_ids if order.state == 'paid'] - move_id = self.pool.get('account.move').create(cr, uid, {'ref' : session.name, 'journal_id' : session.config_id.journal_id.id, }, context=context) + move_id = self.pool.get('account.move').create(cr, uid, {'ref' : session.name, 'journal_id' : session.config_id.journal_id.id, }, context=local_context) - self.pool.get('pos.order')._create_account_move_line(cr, uid, order_ids, session, move_id, context=context) + self.pool.get('pos.order')._create_account_move_line(cr, uid, order_ids, session, move_id, context=local_context) for order in session.order_ids: if order.state not in ('paid', 'invoiced'): @@ -918,23 +919,16 @@ class pos_order(osv.osv): # Tricky, via the workflow, we only have one id in the ids variable """Create a account move line of order grouped by products or not.""" account_move_obj = self.pool.get('account.move') - account_move_line_obj = self.pool.get('account.move.line') account_period_obj = self.pool.get('account.period') account_tax_obj = self.pool.get('account.tax') - user_proxy = self.pool.get('res.users') property_obj = self.pool.get('ir.property') cur_obj = self.pool.get('res.currency') - ctx = dict(context or {}, account_period_prefer_normal=True) - period = account_period_obj.find(cr, uid, context=ctx)[0] - #session_ids = set(order.session_id for order in self.browse(cr, uid, ids, context=context)) if session and not all(session.id == order.session_id.id for order in self.browse(cr, uid, ids, context=context)): raise osv.except_osv(_('Error!'), _('Selected orders do not have the same session!')) - current_company = user_proxy.browse(cr, uid, uid, context=context).company_id - grouped_data = {} have_to_group_by = session and session.config_id.group_by or False @@ -954,7 +948,7 @@ class pos_order(osv.osv): if order.state != 'paid': continue - user_company = user_proxy.browse(cr, order.user_id.id, order.user_id.id).company_id + current_company = order.sale_journal.company_id group_tax = {} account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context) @@ -975,6 +969,7 @@ class pos_order(osv.osv): # if have_to_group_by: sale_journal_id = order.sale_journal.id + period = account_period_obj.find(cr, uid, context=dict(context or {}, company_id=current_company.id, account_period_prefer_normal=True))[0] # 'quantity': line.qty, # 'product_id': line.product_id.id, @@ -984,7 +979,7 @@ class pos_order(osv.osv): 'journal_id' : sale_journal_id, 'period_id' : period, 'move_id' : move_id, - 'company_id': user_company and user_company.id or False, + 'company_id': current_company.id, }) if data_type == 'product': @@ -1025,7 +1020,10 @@ class pos_order(osv.osv): cur = order.pricelist_id.currency_id for line in order.lines: tax_amount = 0 - taxes = [t for t in line.product_id.taxes_id] + taxes = [] + for t in line.product_id.taxes_id: + if t.company_id == current_company.id: + taxes.append(t) computed_taxes = account_tax_obj.compute_all(cr, uid, taxes, line.price_unit * (100.0-line.discount) / 100.0, line.qty)['taxes'] for tax in computed_taxes: