← Back to team overview

openerp-community team mailing list archive

[Merge] lp:~openerp-community/openobject-addons/trunk-bug-1129089 into lp:openobject-addons

 

Bhavesh Tilvani has proposed merging lp:~openerp-community/openobject-addons/trunk-bug-1129089 into lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #1129089 in OpenERP Addons: "[trunk/7.0]Should be constraint on budget line."
  https://bugs.launchpad.net/openobject-addons/+bug/1129089

For more details, see:
https://code.launchpad.net/~openerp-community/openobject-addons/trunk-bug-1129089/+merge/150957

Hello,

create  constraint  when  a end date is less than the start date in Budget line.

Thanks

-- 
https://code.launchpad.net/~openerp-community/openobject-addons/trunk-bug-1129089/+merge/150957
Your team OpenERP Community is subscribed to branch lp:~openerp-community/openobject-addons/trunk-bug-1129089.
=== modified file 'account_budget/account_budget.py'
--- account_budget/account_budget.py	2012-12-17 15:23:03 +0000
+++ account_budget/account_budget.py	2013-02-28 05:50:28 +0000
@@ -185,7 +185,12 @@
             else:
                 res[line.id] = 0.00
         return res
-
+    def _check_dates(self, cr, uid, ids, context=None):
+        for date in self.read(cr, uid, ids, ['date_to', 'date_from'], context=context):
+            if date['date_to'] and date['date_from']:
+                if date['date_from'] > date['date_to']:
+                    return False
+        return True   
     _name = "crossovered.budget.lines"
     _description = "Budget Line"
     _columns = {
@@ -202,6 +207,8 @@
         'company_id': fields.related('crossovered_budget_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True)
     }
 
+    _constraints = [
+        (_check_dates, 'Start Date must be lower than End Date.', ['date_to','date_from'])]
 crossovered_budget_lines()
 
 class account_analytic_account(osv.osv):