[IMP]account-option-wizard
authorPinakin Nayi (OpenERP) <pna@tinyerp.com>
Mon, 23 Jul 2012 06:05:36 +0000 (11:35 +0530)
committerPinakin Nayi (OpenERP) <pna@tinyerp.com>
Mon, 23 Jul 2012 06:05:36 +0000 (11:35 +0530)
bzr revid: pna@tinyerp.com-20120723060536-zb7yue9dm1o4wfx0

addons/account/account.py
addons/account/account_view.xml

index 571ea40..6cb7e14 100644 (file)
@@ -2985,6 +2985,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
 
     _columns = {
         'company_id':fields.many2one('res.company', 'Company', required=True),
+        'currency_id': fields.many2one('res.currency', 'Currency', help="Currency as per company's country."),
         'only_one_chart_template': fields.boolean('Only One Chart Template Available'),
         'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True),
         'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Cash and Banks', required=True),
@@ -2995,6 +2996,27 @@ class wizard_multi_charts_accounts(osv.osv_memory):
         'purchase_tax_rate': fields.float('Purchase Tax(%)'),
         'complete_tax_set': fields.boolean('Complete Set of Taxes', help='This boolean helps you to choose if you want to propose to the user to encode the sales and purchase rates or use the usual m2o fields. This last choice assumes that the set of tax defined for the chosen template is complete'),
     }
+    def _default_company(self, cr, uid, context=None):
+        user_company = self.pool.get('res.users').browse(cr, uid, [uid], context=context)[0].company_id.id
+        return user_company or False
+
+    def _default_currency(self, cr, uid, context=None):
+        company_id=self._default_company(cr, uid, context=context)
+        currency= self.pool.get('res.company').browse(cr, uid, company_id, context=context)
+        return currency.currency_id and currency.currency_id.id or False
+
+    _defaults = {
+        'company_id': _default_company,
+        'currency_id':_default_currency,
+    }
+
+    def onchange_company_id(self, cr, uid, ids, company_id):
+        if company_id:
+            company = self.pool.get('res.company').browse(cr, uid, company_id)
+            return {'value':{'currency_id':company.currency_id and company.currency_id.id}}
+        else :
+            return False
+
     def onchange_tax_rate(self, cr, uid, ids, rate=False, context=None):
         return {'value': {'purchase_tax_rate': rate or False}}
 
index 80202d9..c2b3aa2 100644 (file)
                     <field name="complete_tax_set" invisible="1"/>
                     <div groups="base.group_multi_company">
                         <label for="company_id"/>
-                        <field name="company_id" widget="selection"/> <!-- we assume that this wizard will be run only by administrators and as this field may cause problem if hidden (because of the default company of the user removed from the selection because already configured), we simply choosed to remove the group "multi company" of it -->
+                        <field name="company_id" widget="selection" on_change="onchange_company_id(company_id)"/> <!-- we assume that this wizard will be run only by administrators and as this field may cause problem if hidden (because of the default company of the user removed from the selection because already configured), we simply choosed to remove the group "multi company" of it -->
+                        <field name="currency_id" />
                     </div>
                     <group>
                         <div attrs="{'invisible': [('only_one_chart_template','=',True)]}">