[FIX] account_voucher: implemented on_change to set voucher date based on statement line

bzr revid: rha@tinyerp.com-20130515105728-u4zh5jb4biphx1h8
This commit is contained in:
Rifakat 2013-05-15 16:27:28 +05:30
commit f085de4787
3 changed files with 12 additions and 2 deletions

View File

@ -1645,6 +1645,13 @@ account_bank_statement()
class account_bank_statement_line(osv.osv):
_inherit = 'account.bank.statement.line'
def onchange_line_date(self, cr, uid, ids, date, context=None):
voucher_obj = self.pool.get('account.voucher')
for statement_line in self.browse(cr, uid, ids, context=context):
if statement_line.voucher_id:
voucher_obj.write(cr, uid, [statement_line.voucher_id.id], {'date': date}, context=context)
return {}
def onchange_partner_id(self, cr, uid, ids, partner_id, context=None):
res = super(account_bank_statement_line, self).onchange_partner_id(cr, uid, ids, partner_id, context=context)

View File

@ -221,6 +221,9 @@
<field name="amount" position="attributes">
<attribute name="on_change">onchange_amount(amount)</attribute>
</field>
<xpath expr="//page[@name='statement_line_ids']/field[@name='line_ids']/tree/field[@name='date']" position="attributes">
<attribute name="on_change">onchange_line_date(date)</attribute>
</xpath>
</field>
</record>

View File

@ -94,7 +94,7 @@ class account_statement_from_invoice_lines(osv.osv_memory):
'account_id': result['value'].get('account_id', statement.journal_id.default_credit_account_id.id),
'company_id': statement.company_id.id,
'currency_id': statement.currency.id,
'date': line.date,
'date': statement.date,
'amount': sign*amount,
'payment_rate': result['value']['payment_rate'],
'payment_rate_currency_id': result['value']['payment_rate_currency_id'],
@ -119,7 +119,7 @@ class account_statement_from_invoice_lines(osv.osv_memory):
'statement_id': statement_id,
'ref': line.ref,
'voucher_id': voucher_id,
'date': time.strftime('%Y-%m-%d'),
'date': statement.date,
}, context=context)
return {'type': 'ir.actions.act_window_close'}