[FIX] account, account_voucher: improvement for date and period of bank statement
authorRifakat (OpenERP) <rha@tinyerp.com>
Mon, 20 Feb 2012 06:54:20 +0000 (12:24 +0530)
committerRifakat (OpenERP) <rha@tinyerp.com>
Mon, 20 Feb 2012 06:54:20 +0000 (12:24 +0530)
bzr revid: rha@tinyerp.com-20120220065420-ul2i1xl0jqspq2us

1  2 
addons/account/account_bank_statement.py
addons/account/account_view.xml
addons/account_voucher/account_voucher.py

@@@ -443,6 -443,6 +443,13 @@@ class account_bank_statement_line(osv.o
                  account_id = part.property_account_receivable.id
              res['value']['account_id'] = account_id
          return res
++    
++    def onchange_date(self, cr, uid, statement_lines, date, bank_period_id, context=None):
++        voucher_obj = self.pool.get('account.voucher')
++        for line in self.browse(cr, uid, statement_lines, context=context):
++            if line.voucher_id:
++                voucher_obj.write(cr, uid, [line.voucher_id.id],{'date': date, 'period_id': bank_period_id}, context=context)
++        return True
  
      _order = "statement_id desc, sequence"
      _name = "account.bank.statement.line"
      }
      _defaults = {
          'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'),
--        'date': lambda *a: time.strftime('%Y-%m-%d'),
++        'date': lambda self, cr, uid, context, *a: context.get('date'),
          'type': 'general',
      }
  
                      </group>
                      <notebook colspan="4">
                          <page string="Transaction" name="statement_line_ids">
--                            <field colspan="4" name="line_ids" nolabel="1">
++                            <field colspan="4" name="line_ids" nolabel="1" context="{'date':date}">
                                  <tree editable="bottom" string="Statement lines">
                                      <field name="sequence" readonly="1" invisible="1"/>
--                                    <field name="date" groups="base.group_extended"/>
++                                    <field name="date" groups="base.group_extended" on_change="onchange_date(date)"/>
                                      <field name="name"/>
                                      <field name="ref"/>
                                      <field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
                                      <field name="amount"/>
                                  </tree>
                                  <form string="Statement lines">
--                                    <field name="date"/>
++                                    <field name="date" groups="base.group_extended" on_change="onchange_date(date)"/>
                                      <field name="name"/>
                                      <field name="ref"/>
                                      <field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
@@@ -2580,7 -2580,7 +2580,7 @@@ action = self.pool.get('res.config').ne
  
                      <notebook colspan="4">
                          <page string="Cash Transactions" attrs="{'invisible': [('state','=','draft')]}">
--                            <field colspan="4" name="line_ids" nolabel="1">
++                            <field colspan="4" name="line_ids" nolabel="1" context="{'date':date}">
                                  <tree editable="bottom" string="Statement lines">
                                      <field name="sequence" invisible="1"/>
                                      <field name="date" groups="base.group_extended"/>