Account_analytic_plans:Corrected analytic line creation/modification behaviour from move line creation/modification based on Analytic Distribution,Bugfix on model creation.

bzr revid: jvo@tinyerp.com-20081120110341-ylg9biphgfdnigym
This commit is contained in:
Jay Vora 2008-11-20 16:33:41 +05:30
parent 69dc367ddb
commit 65652235c6
3 changed files with 19 additions and 8 deletions

View File

@ -191,6 +191,9 @@ class account_analytic_plan_instance(osv.osv):
if total_per_plan < item.min_required or total_per_plan > item.max_required:
raise osv.except_osv("Value Error" ,"The Total Should be Between " + str(item.min_required) + " and " + str(item.max_required))
if not vals['name'] and not vals['code']:
raise osv.except_osv('Error', 'Make sure You have entered Name and Code for the model !')
return super(account_analytic_plan_instance, self).create(cr, uid, vals, context)
def write(self, cr, uid, ids, vals, context={}, check=True, update_check=True):
@ -207,9 +210,9 @@ class account_analytic_plan_instance(osv.osv):
#and finally modify the old model to be not a model anymore
vals['plan_id'] = False
if not vals.has_key('name'):
vals['name'] = this.name+'*'
vals['name'] = this.name and (str(this.name)+'*') or "*"
if not vals.has_key('code'):
vals['code'] = this.code+'*'
vals['code'] = this.code and (str(this.code)+'*') or "*"
return self.write(cr, uid, [this.id],vals, context)
else:
#this plan instance isn't a model, so a simple write is fine
@ -311,6 +314,11 @@ class account_move_line(osv.osv):
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
self.called=False
if ('analytics_id' in vals) and (not vals['analytics_id']):
for line in self.browse(cr, uid, ids, context):
toremove = self.pool.get('account.analytic.line').search(cr, uid, [('move_id','=',line.id)], context=context)
if toremove:
self.pool.get('account.analytic.line').unlink(cr, uid, toremove, context=context)
result = super(account_move_line, self).write(cr, uid, ids, vals, context, check, update_check)
self._analytic_update(cr, uid, ids, context)
return result

View File

@ -95,10 +95,10 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Analytic Distribution">
<field name="name"/>
<field name="code"/>
<field name="plan_id"/>
<field name="journal_id"/>
<field name="name" select="1"/>
<field name="code" select="1"/>
<field name="plan_id" select="2"/>
<field name="journal_id" select="2"/>
</tree>
</field>
</record>

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -29,6 +29,7 @@ info = '''<?xml version="1.0"?>
<label string="This distribution model has been saved.\nYou will be able to reuse it later."/>
</form>'''
def activate(self, cr, uid, data, context):
plan_obj = pooler.get_pool(cr.dbname).get('account.analytic.plan.instance')
if data['id']:
@ -43,6 +44,8 @@ def activate(self, cr, uid, data, context):
else:
return 'endit'
def _do_nothing(self, cr, uid, data, context):
return 1
class create_model(wizard.interface):
@ -57,7 +60,7 @@ class create_model(wizard.interface):
},
'endit': {
'actions': [],
'result': {'type':'form', 'arch':'', 'fields':{}, 'state':[('end','OK')]} #FIXME: check
'result': {'type':'action','action':_do_nothing , 'state':'end'} #FIXME: check
},
}
create_model('create.model')