Pinakin Nayi (OpenERP) has proposed merging 
lp:~openerp-commiter/openobject-addons/trunk-company-currency-accounting-option-wizard-pna
 into lp:~openerp-dev/openobject-addons/trunk-company-currency.

Requested reviews:
  Priyesh (OpenERP) (pso-openerp)

For more details, see:
https://code.launchpad.net/~openerp-commiter/openobject-addons/trunk-company-currency-accounting-option-wizard-pna/+merge/116194

Hello,

  I improved Accounting Options wizard and add the options on to select 
currency.

Thanks,
pna
-- 
https://code.launchpad.net/~openerp-commiter/openobject-addons/trunk-company-currency-accounting-option-wizard-pna/+merge/116194
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-company-currency.
=== modified file 'account/account.py'
--- account/account.py	2012-07-18 16:08:28 +0000
+++ account/account.py	2012-07-23 06:14:56 +0000
@@ -2991,6 +2991,7 @@
 
     _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),
@@ -3001,6 +3002,27 @@
         '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}}
 

=== modified file 'account/account_view.xml'
--- account/account_view.xml	2012-07-18 14:28:10 +0000
+++ account/account_view.xml	2012-07-23 06:14:56 +0000
@@ -2409,7 +2409,8 @@
                     <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)]}">

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to