[FIX]: fix a problem of the voucher, and account move line
authorMantavya Gajjar <mga@tinyerp.com>
Fri, 30 Jul 2010 20:59:51 +0000 (02:29 +0530)
committerMantavya Gajjar <mga@tinyerp.com>
Fri, 30 Jul 2010 20:59:51 +0000 (02:29 +0530)
bzr revid: mga@tinyerp.com-20100730205951-f49t3znf1w9p25ef

addons/account/account.py
addons/account/account_move_line.py
addons/account/account_view.xml
addons/account_voucher_payment/account_voucher_payment.py

index b01f659..e19c402 100644 (file)
@@ -1620,13 +1620,41 @@ class account_tax(osv.osv):
         'type_tax_use': fields.selection([('sale','Sale'),('purchase','Purchase'),('all','All')], 'Tax Application', required=True)
 
     }
-    def search(self, cr, uid, args, offset=0, limit=None, order=None,
-            context=None, count=False):
+
+    def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
+        """
+        Returns a list of tupples containing id, name, as internally it is called {def name_get}
+        result format : {[(id, name), (id, name), ...]}
+        
+        @param cr: A database cursor
+        @param user: ID of the user currently logged in
+        @param name: name to search 
+        @param args: other arguments
+        @param operator: default operator is 'ilike', it can be changed
+        @param context: context arguments, like lang, time zone
+        @param limit: Returns first 'n' ids of complete result, default is 80.
+        
+        @return: Returns a list of tupples containing id and name
+        """
+        
+        if not args:
+            args=[]
+        if not context:
+            context={}
+        ids = []
+        ids = self.search(cr, user, args, limit=limit, context=context)
+        return self.name_get(cr, user, ids, context=context)
+    
+    def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
         if context and context.has_key('type'):
-            if context['type'] in ('out_invoice','out_refund'):
-                args.append(('type_tax_use','in',['sale','all']))
-            elif context['type'] in ('in_invoice','in_refund'):
-                args.append(('type_tax_use','in',['purchase','all']))
+            if context.get('type') in ('out_invoice','out_refund'):
+                args += [('type_tax_use','in',['sale','all'])]
+            elif context.get('type') in ('in_invoice','in_refund'):
+                args += [('type_tax_use','in',['purchase','all'])]
+
+        if context and context.has_key('journal_id'):
+            args += [('type_tax_use','in',[context.get('journal_id'),'all'])]
+        
         return super(account_tax, self).search(cr, uid, args, offset, limit, order, context, count)
 
     def name_get(self, cr, uid, ids, context={}):
@@ -1643,6 +1671,7 @@ class account_tax(osv.osv):
         if user.company_id:
             return user.company_id.id
         return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
+        
     _defaults = {
         'python_compute': lambda *a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or None\n# partner : res.partner object or None\n\nresult = price_unit * 0.10''',
         'python_compute_inv': lambda *a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or False\n\nresult = price_unit * 0.10''',
index 9dfb5fe..1d839b0 100644 (file)
@@ -873,20 +873,14 @@ class account_move_line(osv.osv):
             elif field == 'credit':
                 attrs.append('sum="Total credit"')
             elif field == 'account_tax_id':
-                attrs.append('domain="[(\'parent_id\',\'=\',False), (\'type_tax_use\',\'=\',context.get(journal_id.type, \'sale\'))]"')
+                attrs.append('domain="[(\'parent_id\',\'=\',False)]"')
             elif field == 'account_id' and journal.id:
                 attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'&lt;&gt;\',\'view\'), (\'type\',\'&lt;&gt;\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"')
             elif field == 'partner_id':
                 attrs.append('on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"')
-#            elif field == 'date':
-#                attrs.append('on_change="onchange_date(date)"')
-
-#            if field.readonly:
-#                attrs.append('readonly="1"')
-#            if field.required:
-#                attrs.append('required="1"')
-#            else:
-#                attrs.append('required="0"')
+            elif field == 'journal_id':
+                attrs.append("context=\"{'journal_id':journal_id.type}\"")
+
             if field in ('amount_currency','currency_id'):
                 attrs.append('on_change="onchange_currency(account_id, amount_currency,currency_id, date, journal_id)"')
 
index d1cb255..eaae4b3 100644 (file)
                     </group>
                     <notebook colspan="4">
                         <page string="General Information">
-                            <newline/>
-                            <field name="currency_id"/>
-                            <field name="active"/>
-                            <field name="currency_mode"/>
-                            <field name="reconcile"/>
-                            <newline/>
+                            <group col="2" colspan="2">
+                                <separator string="Currency" colspan="2"/>
+                                <field name="currency_id"/>
+                                <field name="currency_mode" attrs="{'readonly': [('currency_id','=',False)]}"/>
+                            </group>
+                            <group col="2" colspan="2">
+                                <separator string="Reconcile" colspan="2"/>
+                                <field name="reconcile"/>
+<!--                                <field name="active"/>-->
+                            </group>
                             <separator string="Default Taxes" colspan="4"/>
                             <field colspan="4" name="tax_ids" nolabel="1" domain="[('parent_id','=',False)]"/>
                             <separator string="Consolidated Children" colspan="4"/>
index 6046e4b..8c4e398 100755 (executable)
@@ -81,10 +81,10 @@ class account_voucher(osv.osv):
         invoice_pool = self.pool.get('account.invoice')
         
         for inv in self.browse(cr, uid, ids):
-
+            
             if inv.move_id:
                 continue
-
+            
             journal = journal_pool.browse(cr, uid, inv.journal_id.id)
             if inv.type in ('journal_pur_voucher', 'journal_sale_vou'):
                 if journal.invoice_sequence_id: