Bharat Devnani (Open ERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-account-asset-add-date-field-bde into lp:~openerp-dev/openobject-addons/trunk-account-asset.
Requested reviews: OpenERP R&D Team (openerp-dev) For more details, see: https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-account-asset-add-date-field-bde/+merge/62604 Hello Sir, I have added the feature of ending period: choose a date and the number of month between 2 depreciations. Thanks & Regards, Devnani Bharat R. -- https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-account-asset-add-date-field-bde/+merge/62604 Your team OpenERP R&D Team is requested to review the proposed merge of lp:~openerp-dev/openobject-addons/trunk-account-asset-add-date-field-bde into lp:~openerp-dev/openobject-addons/trunk-account-asset.
=== modified file 'account_asset/account_asset.py' --- account_asset/account_asset.py 2011-05-24 10:13:39 +0000 +++ account_asset/account_asset.py 2011-05-27 05:39:25 +0000 @@ -99,27 +99,56 @@ day = depreciation_date.day month = depreciation_date.month year = depreciation_date.year - for i in range(1,undone_dotation_number+1): - if i == undone_dotation_number + 1: - amount = residual_amount - else: - if asset.method == 'linear': - amount = asset.purchase_value / undone_dotation_number - else: - amount = residual_amount * asset.method_progress_factor - residual_amount -= amount - vals = { - 'amount': amount, - 'asset_id': asset.id, - 'sequence':i, - 'name': str(asset.id) +'/'+ str(i), - 'remaining_value': residual_amount, - 'depreciated_value': asset.purchase_value - residual_amount, - 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'), - } - self.pool.get('account.asset.depreciation.line').create(cr, uid, vals) - month += asset.method_period - depreciation_date = datetime(year + (month / 12), month % 12, day) + if asset.method_time == 'end': + account = self.pool.get('account.asset.asset') + for value in account.browse(cr, uid, ids, context=context): + purchase_date = datetime.strptime(value.purchase_date, '%Y-%m-%d') + ending_period_date = datetime.strptime(value.ending_period_date, '%Y-%m-%d') + sub_value = (ending_period_date - purchase_date)/(value.method_period * 30) + periods = (sub_value.days) + for i in range(1,periods+1): + if i == undone_dotation_number + 1: + amount = residual_amount + else: + if asset.method == 'linear': + amount = asset.purchase_value / undone_dotation_number + else: + amount = residual_amount * asset.method_progress_factor + residual_amount -= amount + vals = { + 'amount': amount, + 'asset_id': asset.id, + 'sequence':i, + 'name': str(asset.id) +'/'+ str(i), + 'remaining_value': residual_amount, + 'depreciated_value': asset.purchase_value - residual_amount, + 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'), + } + self.pool.get('account.asset.depreciation.line').create(cr, uid, vals) + month += asset.method_period + depreciation_date = datetime(year + (month / 12), month % 12, day) + else: + for i in range(1,undone_dotation_number+1): + if i == undone_dotation_number + 1: + amount = residual_amount + else: + if asset.method == 'linear': + amount = asset.purchase_value / undone_dotation_number + else: + amount = residual_amount * asset.method_progress_factor + residual_amount -= amount + vals = { + 'amount': amount, + 'asset_id': asset.id, + 'sequence':i, + 'name': str(asset.id) +'/'+ str(i), + 'remaining_value': residual_amount, + 'depreciated_value': asset.purchase_value - residual_amount, + 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'), + } + self.pool.get('account.asset.depreciation.line').create(cr, uid, vals) + month += asset.method_period + depreciation_date = datetime(year + (month / 12), month % 12, day) return True def validate(self, cr, uid, ids, context={}): @@ -172,6 +201,7 @@ 'prorata':fields.boolean('Prorata Temporis', Readonly="True", help='Indicates that the accounting entries for this asset have to be done from the purchase date instead of the first January'), 'history_ids': fields.one2many('account.asset.history', 'asset_id', 'History', readonly=True), 'depreciation_line_ids': fields.one2many('account.asset.depreciation.line', 'asset_id', 'Depreciation Lines', readonly=True,), + 'ending_period_date': fields.date("Ending Period Date"), } _defaults = { 'code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'account.asset.code'), @@ -182,7 +212,6 @@ 'method': lambda obj, cr, uid, context: 'linear', 'method_delay': lambda obj, cr, uid, context: 5, 'method_time': lambda obj, cr, uid, context: 'delay', - 'method_period': lambda obj, cr, uid, context: 12, 'method_progress_factor': lambda obj, cr, uid, context: 0.3, '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), === modified file 'account_asset/account_asset_view.xml' --- account_asset/account_asset_view.xml 2011-05-24 10:13:39 +0000 +++ account_asset/account_asset_view.xml 2011-05-27 05:39:25 +0000 @@ -74,9 +74,11 @@ <field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')]}"/> <newline/> <field name="method_time"/> - <field name="method_period" attrs="{'invisible':[('method_time','=','end')]}"/> + <field name="method_period"/> <field name="prorata" colspan="1"/> <field name="method_delay"/> + <label colspan="2"/> + <field name="ending_period_date" attrs="{'invisible':[('method_time','=','delay')],'required':[('method_time','in', ('end'))]}"/> <newline/> </page> <page string="Depreciation board">
_______________________________________________ Mailing list: https://launchpad.net/~openerp-dev-web Post to : openerp-dev-web@lists.launchpad.net Unsubscribe : https://launchpad.net/~openerp-dev-web More help : https://help.launchpad.net/ListHelp