~fleet-maintenance-community/fleet-maintenance/fleet-maintenance

« back to all changes in this revision

Viewing changes to fleet_maintenance/onchange.py

  • Committer: Alexis de Lattre
  • Date: 2012-12-20 18:36:02 UTC
  • Revision ID: alexis@via.ecp.fr-20121220183602-lpp8hhxfq4hklo1h
Also check non_maintenance_line in constraint, to be sure to have "clean" data.

Show diffs side-by-side

added added

removed removed

Lines of Context:
316
316
                    raise osv.except_osv(msg_title, "The Sub Fleet is missing on the line with product '%s'" %line.product_id.name)
317
317
                if line.fleet_id.fleet_type != 'sub_fleet':
318
318
                    raise osv.except_osv(msg_title, "The Sub Fleet '%s' is not of type 'subfleet'" % line.fleet_id.name)
 
319
 
319
320
            if line.product_id.is_maintenance:
320
321
                # At this stage of the code, the value of "maintenance_month_qty" hasn't been
321
322
                # computed yet, so we recompute it here :-(
333
334
                    raise osv.except_osv(msg_title, "The 'maintenance start date' is missing on the line with '%s'" % line.product_id.name)
334
335
                if not line.maintenance_end_date:
335
336
                    raise osv.except_osv(msg_title, "The 'maintenance end date' is missing on the line with '%s'" % line.product_id.name)
 
337
            else:
 
338
                if line.maintenance_start_date:
 
339
                    raise osv.except_osv(msg_title, "The 'maintenance start date' should not have a value on the line with '%s'" % line.product_id.name)
 
340
                if line.maintenance_end_date:
 
341
                    raise osv.except_osv(msg_title, "The 'maintenance end date' should not have a value on the line with '%s'" % line.product_id.name)
 
342
                if line.maintenance_product_qty:
 
343
                    raise osv.except_osv(msg_title, "The 'maintenance product quantity' should be '0' on the line with '%s'" % line.product_id.name)
 
344
 
336
345
        return True
337
346
 
338
347