if sheet: sheet_id = sheet.values()[0][0]
# Comprobamos el estado de la hoja
estado = self._check_estado_hoja(cr, uid, [sheet_id])
# Si el estado es False, significa que esta cerrada
if estado is False:
# Comprobamos si hay valores modificados
if vals: raise osv.except_osv(_('Error!'), _('You cannot create an entry in a Confirmed/Done timesheet!'))
else:
# Si no hay valores modificados, limpiamos los identificadores, para poder saltarnos la comprobacion
ids = []
Ok. I do too a patch for create method.
Write Method:
Same of comment #2
Create Method Override:
def _check_ estado_ hoja(self, cr, uid, ids, context=None):
osv.logging. log(100, "[Alca] _check_ estado_ hoja:hr_ analytic_ timesheet: hr_timesheet_ project" ) get("hr_ timesheet_ sheet.sheet" ).browse( cr, uid, ids[0], context=context)
if context is None:
context = {}
bSheet = self.pool.
if hasattr(bSheet, 'state') and bSheet.state not in ('draft', 'new'):
return False
return True
def create(self, cr, uid, vals, *args, **argv):
osv.logging. log(100, "[Alca] create: hr_analytic_ timesheet: hr_timesheet_ project" + str(vals)) analytic_ timesheet, self).create(cr, uid, vals, *args, **argv)
id_hr = super(hr_
sheet = self._sheet(cr, uid, [id_hr], None, None)
if sheet:
sheet_ id = sheet.values( )[0][0] estado_ hoja(cr, uid, [sheet_id])
raise osv.except_ osv(_(' Error!' ),
_ ('You cannot create an entry in a Confirmed/Done timesheet!'))
# Comprobamos el estado de la hoja
estado = self._check_
# Si el estado es False, significa que esta cerrada
if estado is False:
# Comprobamos si hay valores modificados
if vals:
else:
# Si no hay valores modificados, limpiamos los identificadores, para poder saltarnos la comprobacion
ids = []
return id_hr