~openbig/bigconsulting/changes_in_discount_field

« back to all changes in this revision

Viewing changes to account_invoice_cash_discount/account_invoice_cash_discount.py

  • Committer: husen
  • Date: 2010-08-10 12:19:40 UTC
  • mfrom: (64.1.6 bigconsulting)
  • Revision ID: husen@husen-laptop-20100810121940-y333wq7rz1l0xbt1
Improved tax for import invoice

Show diffs side-by-side

added added

removed removed

Lines of Context:
837
837
 
838
838
class account_bank_statement_line(osv.osv):
839
839
    _inherit="account.bank.statement.line"
840
 
    
841
 
    def _get_tax(self, cr, uid, context={}):
842
 
        tax_id = self.pool.get('account.tax').search(cr, uid, [])
843
 
        if tax_id:
844
 
            return tax_id[0]
845
 
        else:
846
 
            return False    
847
840
    _columns = {
848
841
        'tax_id': fields.many2one('account.tax', 'Tax'),
849
842
        'tax_type': fields.selection([('tax_included','Tax included'),
850
843
                                        ('tax_excluded','Tax excluded')],
851
844
                                        'Tax method', required=True,),
852
845
    }
853
 
    
 
846
      
854
847
    def onchange_account_id(self, cr, uid, ids, account_id, context=None):
855
848
        result={}
856
849
        tax = False
857
850
        taxes = self.pool.get('account.account').browse(cr, uid, account_id, context=context).tax_ids
858
851
        for tax_id in taxes:
859
852
            tax = tax_id.id
860
 
            
861
853
        if tax:
862
854
           result['tax_id'] = tax
863
855
        else:
864
856
           result['tax_id'] = False
865
 
           
 
857
 
 
858
        return {'value': result}
 
859
    
 
860
    def onchange_type(self, cr, uid, ids, type, context=None):
 
861
        result={}
 
862
        tax_id = self.pool.get('account.tax').search(cr, uid, [])
 
863
 
 
864
        if type == 'general' and tax_id:
 
865
           result['tax_id'] = tax_id[0]
 
866
        else:
 
867
            result['tax_id'] =  False
866
868
        return {'value': result}
867
869
    
868
870
    _defaults = {
869
 
        'tax_id': _get_tax,
870
871
        'tax_type':lambda *a :'tax_included',
871
872
    }
872
873
account_bank_statement_line()