Merge lp:~openerp-community/openobject-addons/fix-1127198-import-invoice-payment-date into lp:openobject-addons/7.0

Proposed by Niels Huylebroeck
Status: Merged
Merged at revision: 9799
Proposed branch: lp:~openerp-community/openobject-addons/fix-1127198-import-invoice-payment-date
Merge into: lp:openobject-addons/7.0
Diff against target: 65 lines (+17/-3)
3 files modified
account_voucher/account_voucher.py (+12/-1)
account_voucher/account_voucher_view.xml (+3/-0)
account_voucher/wizard/account_statement_from_invoice.py (+2/-2)
To merge this branch: bzr merge lp:~openerp-community/openobject-addons/fix-1127198-import-invoice-payment-date
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) (community) Approve
Serpent Consulting Services (community) Approve
OpenERP Core Team Pending
Review via email: mp+163006@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Serpent Consulting Services (serpent-consulting-services) wrote :

Faced a similar issue and your fix is perfect!

review: Approve
Revision history for this message
Open Net Sàrl (openerp-open-net) wrote :

Hi,
Could you please review and merge it, It's been such a long time...

Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Hello,

Sorry for the long delay on this one and thanks for your work to fix the bug.

One small remark: Please do not make write calls in on_change methods. on_change should only be for user interface, no impact on the data (eg: if I close my browser after making the change in edit mode without saving).

On the bug report, you mentioned the issue that the date will be changed when confirming is late. On the other hand it is not really problematic as long as these are in draft.
What do you think ?

In the meanwhile I have merged your changes (everything except the on_change) into 7.0

Regards

revno: 9799 [merge]
revision-id: <email address hidden>

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_voucher/account_voucher.py'
2--- account_voucher/account_voucher.py 2013-05-14 11:52:13 +0000
3+++ account_voucher/account_voucher.py 2013-05-15 14:01:27 +0000
4@@ -1619,7 +1619,11 @@
5 bank_st_line_obj = self.pool.get('account.bank.statement.line')
6 st_line = bank_st_line_obj.browse(cr, uid, st_line_id, context=context)
7 if st_line.voucher_id:
8- voucher_obj.write(cr, uid, [st_line.voucher_id.id], {'number': next_number}, context=context)
9+ voucher_obj.write(cr, uid, [st_line.voucher_id.id],
10+ {'number': next_number,
11+ 'date': st_line.date,
12+ 'period_id': st_line.statement_id.period_id.id},
13+ context=context)
14 if st_line.voucher_id.state == 'cancel':
15 voucher_obj.action_cancel_draft(cr, uid, [st_line.voucher_id.id], context=context)
16 wf_service.trg_validate(uid, 'account.voucher', st_line.voucher_id.id, 'proforma_voucher', cr)
17@@ -1645,6 +1649,13 @@
18
19 class account_bank_statement_line(osv.osv):
20 _inherit = 'account.bank.statement.line'
21+
22+ def onchange_line_date(self, cr, uid, ids, date, context=None):
23+ voucher_obj = self.pool.get('account.voucher')
24+ for statement_line in self.browse(cr, uid, ids, context=context):
25+ if statement_line.voucher_id:
26+ voucher_obj.write(cr, uid, [statement_line.voucher_id.id], {'date': date}, context=context)
27+ return {}
28
29 def onchange_partner_id(self, cr, uid, ids, partner_id, context=None):
30 res = super(account_bank_statement_line, self).onchange_partner_id(cr, uid, ids, partner_id, context=context)
31
32=== modified file 'account_voucher/account_voucher_view.xml'
33--- account_voucher/account_voucher_view.xml 2013-04-08 00:55:26 +0000
34+++ account_voucher/account_voucher_view.xml 2013-05-15 14:01:27 +0000
35@@ -221,6 +221,9 @@
36 <field name="amount" position="attributes">
37 <attribute name="on_change">onchange_amount(amount)</attribute>
38 </field>
39+ <xpath expr="//page[@name='statement_line_ids']/field[@name='line_ids']/tree/field[@name='date']" position="attributes">
40+ <attribute name="on_change">onchange_line_date(date)</attribute>
41+ </xpath>
42 </field>
43 </record>
44
45
46=== modified file 'account_voucher/wizard/account_statement_from_invoice.py'
47--- account_voucher/wizard/account_statement_from_invoice.py 2012-12-18 17:55:47 +0000
48+++ account_voucher/wizard/account_statement_from_invoice.py 2013-05-15 14:01:27 +0000
49@@ -94,7 +94,7 @@
50 'account_id': result['value'].get('account_id', statement.journal_id.default_credit_account_id.id),
51 'company_id': statement.company_id.id,
52 'currency_id': statement.currency.id,
53- 'date': line.date,
54+ 'date': statement.date,
55 'amount': sign*amount,
56 'payment_rate': result['value']['payment_rate'],
57 'payment_rate_currency_id': result['value']['payment_rate_currency_id'],
58@@ -119,7 +119,7 @@
59 'statement_id': statement_id,
60 'ref': line.ref,
61 'voucher_id': voucher_id,
62- 'date': time.strftime('%Y-%m-%d'),
63+ 'date': statement.date,
64 }, context=context)
65 return {'type': 'ir.actions.act_window_close'}
66