hr_timesheet_invoice, bill task work: use the analytic account company for the generated invoice_cost_create

This makes life much easiers for people generating billings for several companies.

lp bug: https://launchpad.net/bugs/1047826 fixed

bzr revid: stephane.bidoul@acsone.eu-20120909152438-qax5pv4ij76asmbv
This commit is contained in:
Stéphane Bidoul 2012-09-09 17:24:38 +02:00
parent 17edcf0630
commit 4deb1f84e7
1 changed files with 10 additions and 3 deletions

View File

@ -79,17 +79,24 @@ class account_analytic_line(osv.osv):
curr_invoice = {
'name': time.strftime('%d/%m/%Y')+' - '+account.name,
'partner_id': account.partner_id.id,
'company_id': account.company_id.id,
'payment_term': partner.property_payment_term.id or False,
'account_id': partner.property_account_receivable.id,
'currency_id': account.pricelist_id.currency_id.id,
'date_due': date_due,
'fiscal_position': account.partner_id.property_account_position.id
}
last_invoice = invoice_obj.create(cr, uid, curr_invoice, context=context)
invoices.append(last_invoice)
context2 = context.copy()
context2['lang'] = partner.lang
# set company_id in context, so the correct default journal will be selected
context2['force_company'] = curr_invoice['company_id']
# set force_company in context so the correct product properties are selected (eg. income account)
context2['company_id'] = curr_invoice['company_id']
last_invoice = invoice_obj.create(cr, uid, curr_invoice, context=context2)
invoices.append(last_invoice)
cr.execute("SELECT product_id, to_invoice, sum(unit_amount), product_uom_id, name " \
"FROM account_analytic_line as line " \
"WHERE account_id = %s " \