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
=== modified file 'hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py'
--- hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2011-11-16 14:59:58 +0000
+++ hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2012-09-08 13:39:21 +0000
@@ -81,6 +81,7 @@
81 curr_invoice = {81 curr_invoice = {
82 'name': time.strftime('%d/%m/%Y')+' - '+account.name,82 'name': time.strftime('%d/%m/%Y')+' - '+account.name,
83 'partner_id': account.partner_id.id,83 'partner_id': account.partner_id.id,
84 'company_id': account.company_id.id,
84 'address_contact_id': res_partner_obj.address_get(cr, uid,85 'address_contact_id': res_partner_obj.address_get(cr, uid,
85 [account.partner_id.id], adr_pref=['contact'])['contact'],86 [account.partner_id.id], adr_pref=['contact'])['contact'],
86 'address_invoice_id': res_partner_obj.address_get(cr, uid,87 'address_invoice_id': res_partner_obj.address_get(cr, uid,
@@ -91,11 +92,17 @@
91 'date_due': date_due,92 'date_due': date_due,
92 'fiscal_position': account.partner_id.property_account_position.id93 'fiscal_position': account.partner_id.property_account_position.id
93 }94 }
94 last_invoice = invoice_obj.create(cr, uid, curr_invoice, context=context)95
95 invoices.append(last_invoice)
96
97 context2 = context.copy()96 context2 = context.copy()
98 context2['lang'] = partner.lang97 context2['lang'] = partner.lang
98 # set company_id in context, so the correct default journal will be selected
99 context2['force_company'] = curr_invoice['company_id']
100 # set force_company in context so the correct product properties are selected (eg. income account)
101 context2['company_id'] = curr_invoice['company_id']
102
103 last_invoice = invoice_obj.create(cr, uid, curr_invoice, context=context2)
104 invoices.append(last_invoice)
105
99 cr.execute("SELECT product_id, to_invoice, sum(unit_amount), product_uom_id " \106 cr.execute("SELECT product_id, to_invoice, sum(unit_amount), product_uom_id " \
100 "FROM account_analytic_line as line " \107 "FROM account_analytic_line as line " \
101 "WHERE account_id = %s " \108 "WHERE account_id = %s " \