← Back to team overview

openerp-community team mailing list archive

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

 

Bhavesh Tilvani(OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-bug-1129089-bhavesh 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-dev/openobject-addons/trunk-bug-1129089-bhavesh/+merge/151196

Hello,

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

Thanks

-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1129089-bhavesh/+merge/151196
Your team OpenERP Community is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-bug-1129089-bhavesh.
=== 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-03-01 11:06:15 +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):


Follow ups