Merge lp:~sbi/openobject-addons/6.1-bug1047826 into lp:openobject-addons/6.1

Proposed by Stéphane Bidoul (Acsone)
Status: Needs review
Proposed branch: lp:~sbi/openobject-addons/6.1-bug1047826
Merge into: lp:openobject-addons/6.1
Diff against target: 32 lines (+10/-3)
1 file modified
hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py (+10/-3)
To merge this branch: bzr merge lp:~sbi/openobject-addons/6.1-bug1047826
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+123417@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

6982. By Stéphane Bidoul (Acsone)

hr_timesheet_invoice, bill task work: propose a correct default company for the generated invoice in a multi-company context

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py'
2--- hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2011-11-16 14:59:58 +0000
3+++ hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2012-09-08 13:39:21 +0000
4@@ -81,6 +81,7 @@
5 curr_invoice = {
6 'name': time.strftime('%d/%m/%Y')+' - '+account.name,
7 'partner_id': account.partner_id.id,
8+ 'company_id': account.company_id.id,
9 'address_contact_id': res_partner_obj.address_get(cr, uid,
10 [account.partner_id.id], adr_pref=['contact'])['contact'],
11 'address_invoice_id': res_partner_obj.address_get(cr, uid,
12@@ -91,11 +92,17 @@
13 'date_due': date_due,
14 'fiscal_position': account.partner_id.property_account_position.id
15 }
16- last_invoice = invoice_obj.create(cr, uid, curr_invoice, context=context)
17- invoices.append(last_invoice)
18-
19+
20 context2 = context.copy()
21 context2['lang'] = partner.lang
22+ # set company_id in context, so the correct default journal will be selected
23+ context2['force_company'] = curr_invoice['company_id']
24+ # set force_company in context so the correct product properties are selected (eg. income account)
25+ context2['company_id'] = curr_invoice['company_id']
26+
27+ last_invoice = invoice_obj.create(cr, uid, curr_invoice, context=context2)
28+ invoices.append(last_invoice)
29+
30 cr.execute("SELECT product_id, to_invoice, sum(unit_amount), product_uom_id " \
31 "FROM account_analytic_line as line " \
32 "WHERE account_id = %s " \