Merge branch 'account_analytic/multicompany' into 7.0

Conflicts:
	account_analytic_analysis_recurring/account_analytic_analysis_recurring.py
This commit is contained in:
Federico Cruz
2014-10-23 20:13:11 -05:00

View File

@@ -241,8 +241,30 @@ class AccountAnalyticAccount(orm.Model):
new_date = next_date + relativedelta(months=+interval)
context['old_date'] = old_date
context['next_date'] = new_date
self._prepare_invoice(
cr, uid, contract, context=context)
# Force company for correct evaluate domain access rules
context['force_company'] = contract.company_id.id
# Create new cursor for handle multi company environments
from openerp import pooler
db, pool = pooler.get_db_and_pool(cr.dbname)
cursor = db.cursor()
try:
this = pool.get('account.analytic.account')
# Need to reload contract on new cursor for prevent
# ORM optimizations use same company for load all
# partner properties
contract = this.browse(
cursor, uid, contract.id, context=context
)
this._prepare_invoice(
cursor, uid, contract, context=context
)
cursor.commit() # commit results
except Exception:
cursor.rollback() # error, rollback everything
finally:
cursor.close() # always close cursor
self.write(
cr, uid, [contract.id],
{'recurring_next_date': new_date.strftime('%Y-%m-%d')},