From 6faae72a834b1478d088fd3370d401fc3751d41c Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sat, 26 May 2007 10:03:11 +0000 Subject: [PATCH] Modifs bzr revid: fp@tinyerp.com-119a042c5e35a4555ad17fa4005cb89bc83d5aa7 --- addons/account/account_move_line.py | 4 +-- addons/account/account_view.xml | 6 +++- addons/account/account_wizard.xml | 6 ++-- addons/account/invoice.py | 6 ++-- addons/account_asset/account_asset.py | 32 ++++++++++--------- addons/account_asset/account_asset_view.xml | 12 ++++--- .../account_simulation/account_simulation.py | 2 ++ 7 files changed, 39 insertions(+), 29 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 62bdcbf7438..bbc4af9fb9b 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -167,11 +167,11 @@ class account_move_line(osv.osv): 'credit': fields.float('Credit', digits=(16,2), states={'reconciled':[('readonly',True)]}), 'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", states={'reconciled':[('readonly',True)]}, domain=[('type','<>','view'), ('type', '<>', 'closed')]), - 'move_id': fields.many2one('account.move', 'Entry', required=True, ondelete="cascade", states={'reconciled':[('readonly',True)]}, help="The entry of this entry line.", select=True), + 'move_id': fields.many2one('account.move', 'Entry', required=True, ondelete="cascade", states={'reconciled':[('readonly',True)]}, help="The entry of this entry line.", select=2), 'ref': fields.char('Ref.', size=32), 'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=True), - 'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=True), + 'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=2), 'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optionnal other currency if it is a multi-currency entry."), 'currency_id': fields.many2one('res.currency', 'Currency', help="The optionnal other currency if it is a multi-currency entry."), diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 0568fcb41d6..f783504c345 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -961,7 +961,11 @@ name="account.move.bank.reconcile" menu="False" id="action_account_bank_reconcile_tree" /> - + diff --git a/addons/account/account_wizard.xml b/addons/account/account_wizard.xml index ddca73afa04..260d9f37c4f 100644 --- a/addons/account/account_wizard.xml +++ b/addons/account/account_wizard.xml @@ -57,7 +57,7 @@ name="account.automatic.reconcile" menu="False" id="wizard_automatic_reconcile"/> - @@ -76,7 +76,7 @@ menu="False" id="wizard_reconcile_select"/> @@ -95,7 +95,7 @@ menu="False" id="wizard_unreconcile_select"/> diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 0b9a73f538d..f1958623482 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -401,17 +401,15 @@ class account_invoice(osv.osv): if journal.sequence_id: name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id) - move = {'name': name, 'line_id': line, 'journal_id': journal_id} #, 'state':'posted'} + move = {'name': name, 'line_id': line, 'journal_id': journal_id} if inv.period_id: move['period_id'] = inv.period_id.id for i in line: i[2]['period_id'] = inv.period_id.id move_id = self.pool.get('account.move').create(cr, uid, move) - # make the invoice point to that move self.write(cr, uid, [inv.id], {'move_id': move_id}) - - #self.pool.get('account.move').write(cr, uid, [move_id], {'state':'posted'}) + self.pool.get('account.move').write(cr, uid, [move_id], {'state':'posted'}) self._log_event(cr, uid, ids) return True diff --git a/addons/account_asset/account_asset.py b/addons/account_asset/account_asset.py index f5d597ef55f..f0beb50a26c 100644 --- a/addons/account_asset/account_asset.py +++ b/addons/account_asset/account_asset.py @@ -105,7 +105,7 @@ class account_asset_asset(osv.osv): 'period_id': _get_period, } def _compute_period(self, cr, uid, property, context={}): - if len(property.entry_asset_ids or [])>=property.method_delay: + if (len(property.entry_asset_ids or [])/2)>=property.method_delay: return False if len(property.entry_asset_ids): cp = property.entry_asset_ids[-1].period_id @@ -122,12 +122,16 @@ class account_asset_asset(osv.osv): for move in property.asset_id.entry_ids: total += move.debit-move.credit for move in property.entry_asset_ids: - total += move.debit-move.credit - periods = len(property.entry_asset_ids) - property.method_delay - if property.method == 'linear': - amount = total / periods + if move.account_id == property.account_asset_ids: + total += move.debit-move.credit + periods = (len(property.entry_asset_ids)/2) - property.method_delay + if periods==1: + amount = total else: - amount = total / periods + if property.method == 'linear': + amount = total / periods + else: + amount = total * property.method_progress_factor move_id = self.pool.get('account.move').create(cr, uid, { 'journal_id': property.journal_id.id, @@ -148,10 +152,7 @@ class account_asset_asset(osv.osv): 'partner_id': property.asset_id.partner_id.id, 'date': time.strftime('%Y-%m-%d'), }) - self.pool.get('account.asset.property').write(cr, uid, [property.id], { - 'entry_asset_ids': [(4, id, [])] - }) - id = self.pool.get('account.move.line').create(cr, uid, { + id2 = self.pool.get('account.move.line').create(cr, uid, { 'name': property.name or property.asset_id.name, 'move_id': move_id, 'account_id': property.account_actif_id.id, @@ -164,9 +165,9 @@ class account_asset_asset(osv.osv): 'date': time.strftime('%Y-%m-%d'), }) self.pool.get('account.asset.property').write(cr, uid, [property.id], { - 'entry_actif_ids': [(4, id, False)] + 'entry_asset_ids': [(4, id2, False),(4,id,False)] }) - if property.method_delay - len(property.entry_asset_ids)<=1: + if property.method_delay - (len(property.entry_asset_ids)/2)<=1: self.pool.get('account.asset.property')._close(cr, uid, property, context) return result return result @@ -202,7 +203,7 @@ class account_asset_property(osv.osv): def _amount_residual(self, cr, uid, ids, name, args, context={}): id_set=",".join(map(str,ids)) cr.execute("""SELECT - r.asset_property_id,abs(SUM(l.debit-l.credit)) AS amount + r.asset_property_id,SUM(abs(l.debit-l.credit)) AS amount FROM account_move_asset_entry_rel r LEFT JOIN @@ -243,6 +244,7 @@ class account_asset_property(osv.osv): 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'), 'method': fields.selection([('linear','Linear'),('progressif','Progressive')], 'Computation method', required=True, readonly=True, states={'draft':[('readonly',False)]}), + 'method_progress_factor': fields.float('Progressif factor', readonly=True, states={'draft':[('readonly',False)]}), 'method_time': fields.selection([('delay','Delay'),('end','Ending period')], 'Time method', required=True, readonly=True, states={'draft':[('readonly',False)]}), 'method_delay': fields.integer('Number of interval', readonly=True, states={'draft':[('readonly',False)]}), 'method_period': fields.integer('Period per interval', readonly=True, states={'draft':[('readonly',False)]}), @@ -251,7 +253,6 @@ class account_asset_property(osv.osv): 'date': fields.date('Date created'), 'entry_asset_ids': fields.many2many('account.move.line', 'account_move_asset_entry_rel', 'asset_property_id', 'move_id', 'Asset Entries'), - 'entry_actif_ids': fields.many2many('account.move.line', 'account_move_asset_actif_entry_rel', 'asset_property_id', 'move_id', 'Asset Entries'), 'board_ids': fields.one2many('account.asset.board', 'asset_id', 'Asset board'), 'value_total': fields.function(_amount_total, method=True, digits=(16,2),string='Gross value'), @@ -264,6 +265,7 @@ class account_asset_property(osv.osv): 'state': lambda obj, cr, uid, context: 'draft', 'method': lambda obj, cr, uid, context: 'linear', 'method_time': lambda obj, cr, uid, context: 'delay', + 'method_progress_factor': lambda obj, cr, uid, context: 0.3, 'method_delay': lambda obj, cr, uid, context: 5, 'method_period': lambda obj, cr, uid, context: 12, 'date': lambda obj, cr, uid, context: time.strftime('%Y-%m-%d') @@ -273,7 +275,7 @@ account_asset_property() class account_move_line(osv.osv): _inherit = 'account.move.line' _columns = { - 'asset_id': fields.many2one('account.asset.asset', 'Asset', relate=True), + 'asset_id': fields.many2one('account.asset.asset', 'Asset'), } account_move_line() diff --git a/addons/account_asset/account_asset_view.xml b/addons/account_asset/account_asset_view.xml index 64eb38e0ff8..2737a717d69 100644 --- a/addons/account_asset/account_asset_view.xml +++ b/addons/account_asset/account_asset_view.xml @@ -80,18 +80,22 @@ - -