Divyesh Makwana(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-893523-mdi into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #893523 in OpenERP Addons: "Asset in multi company: impossible to 
create/post items for subsidiary"
  https://bugs.launchpad.net/openobject-addons/+bug/893523

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-893523-mdi/+merge/85445

Hello Sir,

I have fix the issue: https://bugs.launchpad.net/openobject-addons/+bug/893523 
"Asset in multi company: impossible to create/post items for subsidiary".

Thanks and Regards,

Divyesh Makwana(MDI)
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-893523-mdi/+merge/85445
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-893523-mdi.
=== modified file 'account_asset/account_asset.py'
--- account_asset/account_asset.py	2011-11-11 19:29:54 +0000
+++ account_asset/account_asset.py	2011-12-13 08:45:34 +0000
@@ -131,7 +131,7 @@
         if asset.prorata:
             undone_dotation_number += 1
         return undone_dotation_number
-    
+
     def compute_depreciation_board(self, cr, uid, ids, context=None):
         depreciation_lin_obj = self.pool.get('account.asset.depreciation.line')
         for asset in self.browse(cr, uid, ids, context=context):
@@ -141,7 +141,7 @@
             old_depreciation_line_ids = depreciation_lin_obj.search(cr, uid, [('asset_id', '=', asset.id), ('move_id', '=', False)])
             if old_depreciation_line_ids:
                 depreciation_lin_obj.unlink(cr, uid, old_depreciation_line_ids, context=context)
-            
+
             amount_to_depr = residual_amount = asset.value_residual
             if asset.prorata:
                 depreciation_date = datetime.strptime(self._get_last_depreciation_date(cr, uid, [asset.id], context)[asset.id], '%Y-%m-%d')
@@ -198,6 +198,16 @@
             res.setdefault(id, 0.0)
         return res
 
+    def onchange_company_id(self, cr, uid, ids, company_id, context=None):
+        val = {}
+        if company_id:
+            company = self.pool.get('res.company').browse(cr, uid, company_id, context=context)
+            if company.currency_id.company_id and company.currency_id.company_id.id != company_id:
+                val['currency_id'] = False
+            else:
+                val['currency_id'] = company.currency_id.id
+        return {'value': val}
+
     _columns = {
         'account_move_line_ids': fields.one2many('account.move.line', 'asset_id', 'Entries', readonly=True, states={'draft':[('readonly',False)]}),
         'name': fields.char('Asset', size=64, required=True, readonly=True, states={'draft':[('readonly',False)]}),
@@ -224,7 +234,7 @@
         'method_end': fields.date('Ending Date', readonly=True, states={'draft':[('readonly',False)]}),
         'method_progress_factor': fields.float('Degressive Factor', readonly=True, states={'draft':[('readonly',False)]}),
         'value_residual': fields.function(_amount_residual, method=True, digits_compute=dp.get_precision('Account'), string='Residual Value'),
-        'method_time': fields.selection([('number','Number of Depreciations'),('end','Ending Date')], 'Time Method', required=True, readonly=True, states={'draft':[('readonly',False)]}, 
+        'method_time': fields.selection([('number','Number of Depreciations'),('end','Ending Date')], 'Time Method', required=True, readonly=True, states={'draft':[('readonly',False)]},
                                   help="Choose the method to use to compute the dates and number of depreciation lines.\n"\
                                        "  * Number of Depreciations: Fix the number of depreciation lines and the time between 2 depreciations.\n" \
                                        "  * Ending Date: Choose the time between 2 depreciations and the date the depreciations won't go beyond."),
@@ -246,7 +256,7 @@
         'currency_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id,
         'company_id': lambda self, cr, uid, context: self.pool.get('res.company')._company_default_get(cr, uid, 'account.asset.asset',context=context),
     }
-    
+
     def _check_recursion(self, cr, uid, ids, context=None, parent=None):
         return super(account_asset_asset, self)._check_recursion(cr, uid, ids, context=context, parent=parent)
 
@@ -295,7 +305,7 @@
         result = []
         period_obj = self.pool.get('account.period')
         depreciation_obj = self.pool.get('account.asset.depreciation.line')
-        period = period_obj.browse(cr, uid, period_id, context=context) 
+        period = period_obj.browse(cr, uid, period_id, context=context)
         depreciation_ids = depreciation_obj.search(cr, uid, [('asset_id', 'in', ids), ('depreciation_date', '<', period.date_stop), ('depreciation_date', '>', period.date_start), ('move_check', '=', False)], context=context)
         return depreciation_obj.create_move(cr, uid, depreciation_ids, context=context)
 
@@ -394,7 +404,7 @@
             self.write(cr, uid, line.id, {'move_id': move_id}, context=context)
             created_move_ids.append(move_id)
             if can_close:
-                asset_obj.write(cr, uid, [line.asset_id.id], {'state': 'close'}, context=context)                
+                asset_obj.write(cr, uid, [line.asset_id.id], {'state': 'close'}, context=context)
         return created_move_ids
 
 account_asset_depreciation_line()
@@ -416,7 +426,7 @@
         'user_id': fields.many2one('res.users', 'User', required=True),
         'date': fields.date('Date', required=True),
         'asset_id': fields.many2one('account.asset.asset', 'Asset', required=True),
-        'method_time': fields.selection([('number','Number of Depreciations'),('end','Ending Date')], 'Time Method', required=True, 
+        'method_time': fields.selection([('number','Number of Depreciations'),('end','Ending Date')], 'Time Method', required=True,
                                   help="The method to use to compute the dates and number of depreciation lines.\n"\
                                        "Number of Depreciations: Fix the number of depreciation lines and the time between 2 depreciations.\n" \
                                        "Ending Date: Choose the time between 2 depreciations and the date the depreciations won't go beyond."),
@@ -430,7 +440,7 @@
         'date': lambda *args: time.strftime('%Y-%m-%d'),
         'user_id': lambda self, cr, uid, ctx: uid
     }
-    
+
 account_asset_history()
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'account_asset/account_asset_view.xml'
--- account_asset/account_asset_view.xml	2011-12-12 22:30:17 +0000
+++ account_asset/account_asset_view.xml	2011-12-13 08:45:34 +0000
@@ -2,7 +2,7 @@
 <data>
 
     <!--
-        Asset Category 
+        Asset Category
      -->
 
     <record model="ir.ui.view" id="view_account_asset_category_form">
@@ -87,7 +87,7 @@
                  <field name="salvage_value"/>
                  <field name="value_residual"/>
                  <field name="currency_id"/>
-                 <field name="company_id" widget="selection" groups="base.group_multi_company"/>
+                 <field name="company_id" widget="selection" groups="base.group_multi_company" on_change="onchange_company_id(company_id)"/>
               </group>
               <notebook colspan="4">
                  <page string="General">
@@ -103,7 +103,7 @@
                         <field name="method_period"/>
                         <field name="method_end" attrs="{'required': [('method_time','=','end')], 'invisible':[('method_time','=','number')]}"/>
                         <newline/>
-                        <button name="%(action_asset_modify)d" states="open" string="Change Duration" type="action" icon="terp-stock_effects-object-colorize" colspan="2"/> 
+                        <button name="%(action_asset_modify)d" states="open" string="Change Duration" type="action" icon="terp-stock_effects-object-colorize" colspan="2"/>
                     </group>
                     <group colspan="2" col="2">
                         <separator string="Depreciation Method" colspan="2"/>
@@ -209,9 +209,9 @@
             </search>
         </field>
     </record>
-    
+
     <!--
-        Asset History 
+        Asset History
      -->
 
     <record model="ir.ui.view" id="view_account_asset_history_form">
@@ -274,7 +274,7 @@
             </field>
         </field>
     </record>
-    
+
     <record id="view_account_move_line_filter_inherit" model="ir.ui.view">
         <field name="name">Journal Items (Search)</field>
         <field name="model">account.move.line</field>
@@ -302,7 +302,7 @@
     </record>
 
     <menuitem parent="menu_finance_assets" id="menu_action_account_asset_asset_form" action="action_account_asset_asset_form"/>
-    
+
     <act_window id="act_entries_open" name="Entries" res_model="account.move.line" src_model="account.asset.asset" context="{'search_default_asset_id': [active_id], 'default_asset_id': active_id}"/>
 
     <menuitem id="menu_finance_config_assets" name="Assets" parent="account.menu_finance_accounting"/>
@@ -314,19 +314,19 @@
     </record>
 
     <menuitem parent="menu_finance_config_assets" id="menu_action_account_asset_asset_list_normal" action="action_account_asset_asset_list_normal"/>
-    
+
     <record model="ir.actions.act_window" id="action_account_asset_asset_form_normal">
         <field name="name">Review Asset Categories</field>
         <field name="res_model">account.asset.category</field>
         <field name="view_type">form</field>
         <field name="view_mode">tree,form</field>
     </record>
-    
+
     <record id="asset_category_form_view_todo" model="ir.actions.todo">
         <field name="action_id" ref="action_account_asset_asset_form_normal"/>
         <field name="category_id" ref="account.category_accounting_configuration"/>
         <field name="sequence">3</field>
     </record>
-    
+
 </data>
 </openerp>

_______________________________________________
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