[MERGE] Forward-port of latest 7.0 bugfixes, up to rev. 9814 revid:dle@openerp.com-20140206163444-ckcmurcwk2vhi5vp

bzr revid: dle@openerp.com-20140206164522-fi05cb4mpg22rkv2
This commit is contained in:
Denis Ledoux 2014-02-06 17:45:22 +01:00
commit 041f1db4a6
4 changed files with 18 additions and 15 deletions

View File

@ -1452,7 +1452,7 @@
<act_window
id="act_account_move_to_account_move_line_open"
name="Journal Items"
context="{'search_default_journal_id': active_id, 'default_journal_id': active_id}"
context="{'search_default_move_id': active_id, 'default_move_id': active_id}"
res_model="account.move.line"
src_model="account.move"/>

View File

@ -1366,6 +1366,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)
@ -1380,7 +1381,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 = []
@ -1392,9 +1393,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,

View File

@ -1509,6 +1509,9 @@ class mail_thread(osv.AbstractModel):
if context.get('operation', '') != 'create':
try:
self.check_access_rights(cr, uid, 'read')
if context.get('operation', '') == 'create':
self.check_access_rule(cr, uid, ids, 'create')
else:
self.check_access_rule(cr, uid, ids, 'read')
except (osv.except_osv, orm.except_orm):
return False

View File

@ -457,11 +457,12 @@ class pos_session(osv.osv):
account_move_obj = self.pool.get('account.move')
pos_order_obj = self.pool.get('pos.order')
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 = account_move_obj.create(cr, uid, {'ref' : session.name, 'journal_id' : session.config_id.journal_id.id, }, context=context)
move_id = account_move_obj.create(cr, uid, {'ref' : session.name, 'journal_id' : session.config_id.journal_id.id, }, context=local_context)
pos_order_obj._create_account_move_line(cr, uid, order_ids, session, move_id, context=context)
pos_order_obj._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'):
@ -932,22 +933,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')
period = account_period_obj.find(cr, uid, context=context)[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
@ -967,7 +962,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)
@ -988,6 +983,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))[0]
# 'quantity': line.qty,
# 'product_id': line.product_id.id,
@ -997,7 +993,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':
@ -1038,7 +1034,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: