Somesh Khare(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.1-opw-572620-skh into 
lp:openobject-addons/6.1.

Requested reviews:
  Naresh(OpenERP) (nch-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-572620-skh/+merge/97150

Hello,

[Fix]: Analytic account should not be deleted when it has some analytic entries 
in it.

Kindly review the branch and please share your view on it.

Thanks,
Somesh khare
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-572620-skh/+merge/97150
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.1-opw-572620-skh.
=== modified file 'analytic/analytic.py'
--- analytic/analytic.py	2012-02-16 18:01:11 +0000
+++ analytic/analytic.py	2012-03-13 06:47:20 +0000
@@ -278,6 +278,18 @@
         else:
             account = self.search(cr, uid, args, limit=limit, context=context)
         return self.name_get(cr, uid, account, context=context)
+    
+    def _check_existing_analytic_line(self, cr, uid, ids, method, context=None):
+        line_obj = self.pool.get('account.analytic.line')
+        account_ids = self.search(cr, uid, [('id', 'child_of', ids)])
+        if line_obj.search(cr, uid, [('account_id', 'in', account_ids)]):
+            if method == 'unlink':
+                raise osv.except_osv(_('Error !'), _('You cannot remove an analytic account which has analytic entries!. Remove the related analytic entries first.'))
+        return True
+
+    def unlink(self, cr, uid, ids, context=None):
+         self._check_existing_analytic_line(cr, uid, ids, "unlink", context=context)
+         return super(account_analytic_account, self).unlink(cr, uid, ids, context=context)
 
 account_analytic_account()
 

_______________________________________________
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