Merge lp:~therp-nl/openobject-addons/7.0-lp1213852-select_invoicing_contact_on_invoice_form into lp:openobject-addons/7.0

Proposed by Stefan Rijnhart (Opener)
Status: Needs review
Proposed branch: lp:~therp-nl/openobject-addons/7.0-lp1213852-select_invoicing_contact_on_invoice_form
Merge into: lp:openobject-addons/7.0
Diff against target: 22 lines (+12/-0)
1 file modified
account/account_invoice.py (+12/-0)
To merge this branch: bzr merge lp:~therp-nl/openobject-addons/7.0-lp1213852-select_invoicing_contact_on_invoice_form
Reviewer Review Type Date Requested Status
Stéphane Bidoul (Acsone) (community) code review Approve
OpenERP Core Team Pending
Review via email: mp+180818@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

It seems to me the proposed patch may create difficulties when there is more than one invoice address defined, by resetting the user choice to the first invoice address found.

review: Needs Information (code review)
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

It seems to me that when you manually select an invoice contact, then the result of address_get() would be that same contact. However, you would need to make such a contact a customer/supplier to select it in the first place. Does that answer your question?

Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

Yes, absolutely!

review: Approve (code review)

Unmerged revisions

9368. By Stefan Rijnhart (Opener)

[FIX] Select invoicing contact on invoice form

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account_invoice.py'
2--- account/account_invoice.py 2013-07-12 06:58:43 +0000
3+++ account/account_invoice.py 2013-08-19 09:55:40 +0000
4@@ -480,6 +480,18 @@
5
6 def onchange_partner_id(self, cr, uid, ids, type, partner_id,\
7 date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):
8+ # Select the preferred invoice contact, if any
9+ if partner_id:
10+ partner_invoice_id = self.pool.get('res.partner').address_get(
11+ cr, uid, [partner_id], adr_pref=['invoice'])['invoice']
12+ if partner_invoice_id != partner_id:
13+ result = self.onchange_partner_id(
14+ cr, uid, ids, type, partner_invoice_id,
15+ date_invoice=date_invoice, payment_term=payment_term,
16+ partner_bank_id=partner_bank_id, company_id=company_id)
17+ result['value']['partner_id'] = partner_invoice_id
18+ return result
19+
20 partner_payment_term = False
21 acc_id = False
22 bank_id = False