[FIX] account_payment:
authorRifakat (OpenERP) <rha@tinyerp.com>
Tue, 8 Nov 2011 10:45:56 +0000 (16:15 +0530)
committerRifakat (OpenERP) <rha@tinyerp.com>
Tue, 8 Nov 2011 10:45:56 +0000 (16:15 +0530)
* able to make payment order in draft state from done state
* not possible to cancel Payment order which is already imported in Bank statement
* can create DTA file

bzr revid: rha@tinyerp.com-20111108104556-iqwe1jh7gwv8m7cs

1  2 
addons/account_payment/account_payment.py
addons/account_payment/account_payment_workflow.xml
addons/account_payment/wizard/account_payment_populate_statement.py
addons/l10n_ch/wizard/create_dta.py

@@@ -23,6 -23,6 +23,7 @@@ import tim
  
  from osv import osv, fields
  import netsvc
++from tools.translate import _
  
  class payment_mode(osv.osv):
      _name= 'payment.mode'
@@@ -119,6 -120,6 +121,16 @@@ class payment_order(osv.osv)
                  reference = ir_seq_obj.get(cr, uid, 'payment.order')
                  self.write(cr, uid, order['id'], {'reference':reference})
          return True
++    
++    def action_cancel(self, cr, uid, ids, *args):
++        for order in self.browse(cr, uid, ids):
++            for line in order.line_ids:
++                if line.bank_statement_line_id:
++                    raise osv.except_osv(_('Warning !'),
++                    _('Payment order line "%s" is already imported in Bank statement "%s".')\
++                    %(line.name, line.bank_statement_line_id.statement_id.name,))
++        self.write(cr, uid, ids, {'state': 'cancel'})
++        return True
  
      def set_done(self, cr, uid, ids, *args):
          wf_service = netsvc.LocalService("workflow")
@@@ -31,7 -31,7 +31,7 @@@ write({'state':'open'})</field
          <record id="act_cancel" model="workflow.activity">
              <field name="name">cancel</field>
              <field name="wkf_id" ref="wkf_payment_order"/>
--            <field name="action">write({'state':'cancel'})</field>
++            <field name="action">action_cancel()</field>
              <field name="kind">function</field>
              <field name="flow_stop">True</field>
          </record>
@@@ -79,7 -79,7 +79,7 @@@ class account_payment_populate_statemen
              if not line.move_line_id.id:
                  continue
              context.update({'move_line_ids': [line.move_line_id.id]})
--            result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), voucher_currency_id= statement.currency.id, ttype='payment', date=line.ml_maturity_date, context=context)
++            result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id= statement.currency.id, ttype='payment', date=line.ml_maturity_date, context=context)
  
              voucher_res = {
                      'type': 'payment',
@@@ -349,7 -349,7 +349,7 @@@ def _create_dta(obj, cr, uid, data, con
  
      v['comp_bank_name']= bank.bank and bank.bank.name or False
      v['comp_bank_clearing'] = bank.bank.clearing
--
++    
      if not v['comp_bank_clearing']:
          raise osv.except_osv(_('Error'),
                  _('You must provide a Clearing Number for your bank account.'))
@@@ -580,6 -580,6 +580,7 @@@ class create_dta_wizard(osv.osv_memory)
          data['ids'] = active_ids
          data['id'] = active_id
          dta_file = _create_dta(self, cr, uid, data, context)
++        self.write(cr, uid, ids, {'dta_file': dta_file['dta']}, context=context)
          context.update({'dta_file':dta_file})
          return self.save_dta(cr, uid, ids, context)
  
          return {
              'view_type': 'form',
              'view_mode': 'form',
++            'res_id': ids[0],
              'res_model': 'create.dta.wizard',
              'views': [(resource_id, 'form')],
              'type': 'ir.actions.act_window',