def enable_translations(self, cr, context): """ pass a cr object and a context dictionnary that contain the 'lang' key to this method to allow label translations otherwise, labels (such as scales names) stay in english """ #I do it this way because translations only work where cr and context are defined translations = {} translations['Years'] = _('Years') translations['Months'] = _('Months') translations['Weeks'] = _('Weeks') translations['Days'] = _('Days') self.data.set_translations(translations)
def enable_translations(self, cr, context): """ pass a cr object and a context dictionnary that contain the 'lang' key to this method to allow label translations otherwise, labels (such as scales names) stay in english """ # I do it this way because translations only work where cr and context are defined translations = {} translations["Years"] = _("Years") translations["Months"] = _("Months") translations["Weeks"] = _("Weeks") translations["Days"] = _("Days") self.data.set_translations(translations)
def get_message_id(self, cr, uid, context): """ return the message'id. create one if the message does not exists """ message_id = 0 try: #there is only one line in db, let's get it message_id = int(self.search(cr, uid, [], offset=0, limit=1, context=context)[0]) except Exception: #"unable to find the message". I ignore this error and try to create the message if it does not exists pass #the message does not exists if message_id == 0: #translate self.message['subject'] = _('Timesheet Reminder') self.message['message'] = _('At least one of your last timesheets is still in draft or is missing. Please take time to complete and confirm it.') message_id = self.create(cr, uid, self.message, context) return message_id
def _get_downpayement_builder(self, cr, context, project): """ return the downpayment table """ builder = SimpleRowsTableBuilder(_("Down Payments")) builder.add_date_column(_("Date"), 20 * mm) builder.add_text_column(_("Description")) builder.add_text_column(_("Invoice")) builder.add_money_column(_("Amount")) builder.add_money_column( _("Amount") + " [" + project.company_id.currency_id.name + "]") payments = self.get_down_payments(project) if len(payments) == 0: return False for p in payments: builder.add_date_cell(time.strptime(p['date'], "%Y-%m-%d")) builder.add_text_cell(p['name']) builder.add_text_cell(p['nbr']) builder.add_money_cell(p['amount'], p['currency']) builder.add_money_cell(p['amount_company_currency'], project.company_id.currency_id.name) builder.add_empty_cell() builder.add_text_cell("<b>Total:</b>") builder.add_empty_cell() builder.add_empty_cell() builder.add_subtotal_money_cell(project.company_id.currency_id.name) return builder
def _get_downpayement_builder(self, cr, context, project): """ return the downpayment table """ builder = SimpleRowsTableBuilder(_("Down Payments")) builder.add_date_column(_("Date"), 20*mm) builder.add_text_column(_("Description")) builder.add_text_column(_("Invoice")) builder.add_money_column(_("Amount")) builder.add_money_column(_("Amount")+" ["+project.company_id.currency_id.name+"]") payments = self.get_down_payments(project) if len(payments) == 0: return False for p in payments: builder.add_date_cell(time.strptime(p['date'], "%Y-%m-%d")) builder.add_text_cell(p['name']) builder.add_text_cell(p['nbr']) builder.add_money_cell(p['amount'], p['currency']) builder.add_money_cell(p['amount_company_currency'], project.company_id.currency_id.name) builder.add_empty_cell() builder.add_text_cell("<b>Total:</b>") builder.add_empty_cell() builder.add_empty_cell() builder.add_subtotal_money_cell(project.company_id.currency_id.name) return builder
def get_message_id(self, cr, uid, context): """ return the message'id. create one if the message does not exists """ message_id = 0 try: #there is only one line in db, let's get it message_id = int( self.search(cr, uid, [], offset=0, limit=1, context=context)[0]) except Exception: #"unable to find the message". I ignore this error and try to create the message if it does not exists pass #the message does not exists if message_id == 0: #translate self.message['subject'] = _('Timesheet Reminder') self.message['message'] = _( 'At least one of your last timesheets is still in draft or is missing. Please take time to complete and confirm it.' ) message_id = self.create(cr, uid, self.message, context) return message_id
def _get_supplier_invoice_builder(self, cr, context, project, open_only): """ Return the supplier invoices flowable object. Return false if there is no invoices """ builder = SimpleRowsTableBuilder(_("Suppliers Invoices")) builder.add_text_column(_("Ref"), 20 * mm) builder.add_text_column(_("Description")) builder.add_text_column(_("Partner")) builder.add_text_column(_("State"), 15 * mm) builder.add_date_column(_("Due Date"), 20 * mm) builder.add_money_column(_("Amount"), 40 * mm) builder.add_money_column( _("Amount") + " [" + project.company_id.currency_id.name + "]", 40 * mm) invoices = self.get_invoices(project, open_only, True) if (len(invoices) == 0): return False for invoice in invoices: total = invoice['total'] i = invoice['object'] builder.add_text_cell(i.number) builder.add_text_cell(i.name) builder.add_text_cell(i.partner_id.name) builder.add_text_cell(i.state) builder.add_date_cell(i.date_due) builder.add_money_cell(total, i.currency_id.name) builder.add_money_cell(invoice['total_currency'], project.company_id.currency_id.name) builder.add_empty_cell() builder.add_text_cell("<b>Total:</b>") builder.add_empty_cell() builder.add_empty_cell() builder.add_empty_cell() builder.add_empty_cell() builder.add_subtotal_money_cell(project.company_id.currency_id.name) return builder
def _get_detail_builder(self, cr, context, project): """ return the table that contain project details """ builder = KeyValueTableBuilder(_("Details")) #simple table one column of keys, one column of values builder.add_key_column(30 * mm) builder.add_value_column() ### # add pairs of key & value ### builder.add_key_cell(_("Name:")) builder.add_text_cell(project.name) builder.add_key_cell(_("Code:")) builder.add_text_cell(project.code) builder.add_key_cell(_("Parent Project:")) builder.add_text_cell( (project.parent_id and project.parent_id.code or '')+\ " "+\ (project.parent_id and project.parent_id.name or '-') ) builder.add_key_cell(_("Customer:")) builder.add_text_cell( project.partner_id and \ project.partner_id.name or '-' ) builder.add_key_cell(_("Contact:")) builder.add_text_cell( project.contact_id and\ project.contact_id.name or '-' ) builder.add_key_cell(_("Manager:")) builder.add_text_cell( project.user_id and\ project.user_id.name or '-' ) return builder
def _get_detail_builder(self, cr, context, project): """ return the table that contain project details """ builder = KeyValueTableBuilder(_("Details")) #simple table one column of keys, one column of values builder.add_key_column(30*mm) builder.add_value_column() ### # add pairs of key & value ### builder.add_key_cell(_("Name:")) builder.add_text_cell( project.name ) builder.add_key_cell(_("Code:")) builder.add_text_cell( project.code ) builder.add_key_cell(_("Parent Project:")) builder.add_text_cell( (project.parent_id and project.parent_id.code or '')+\ " "+\ (project.parent_id and project.parent_id.name or '-') ) builder.add_key_cell(_("Customer:")) builder.add_text_cell( project.partner_id and \ project.partner_id.name or '-' ) builder.add_key_cell(_("Contact:")) builder.add_text_cell( project.contact_id and\ project.contact_id.name or '-' ) builder.add_key_cell(_("Manager:")) builder.add_text_cell( project.user_id and\ project.user_id.name or '-' ) return builder
def _get_supplier_invoice_builder(self, cr, context, project, open_only): """ Return the supplier invoices flowable object. Return false if there is no invoices """ builder = SimpleRowsTableBuilder(_("Suppliers Invoices")) builder.add_text_column(_("Ref"), 20*mm) builder.add_text_column(_("Description")) builder.add_text_column(_("Partner")) builder.add_text_column(_("State"), 15*mm) builder.add_date_column(_("Due Date"), 20*mm) builder.add_money_column(_("Amount"), 40*mm) builder.add_money_column(_("Amount")+" ["+project.company_id.currency_id.name+"]", 40*mm) invoices = self.get_invoices(project, open_only, True) if (len(invoices) == 0): return False for invoice in invoices: total = invoice['total'] i = invoice['object'] builder.add_text_cell(i.number) builder.add_text_cell(i.name) builder.add_text_cell(i.partner_id.name) builder.add_text_cell(i.state) builder.add_date_cell(i.date_due) builder.add_money_cell(total, i.currency_id.name) builder.add_money_cell(invoice['total_currency'], project.company_id.currency_id.name) builder.add_empty_cell() builder.add_text_cell("<b>Total:</b>") builder.add_empty_cell() builder.add_empty_cell() builder.add_empty_cell() builder.add_empty_cell() builder.add_subtotal_money_cell(project.company_id.currency_id.name) return builder
def get_template_title(self, cr, context): """ return the title of the report """ return _("Budget Vs. Actual")
def get_template_title(self, cr, context): """ return the title of the report """ return _("Budget by Periods")
def get_template_title(self, cr, context): """ return the title of the report """ return _("Budget Consolidation")
def create(self, cr, uid, ids, datas, context={}): """ construct the report """ #init self.cr = cr self.uid = uid self.datas = datas self.context = context self.pool = pooler.get_pool(self.cr.dbname) #get the is of products flagged as downpayment self.downpayments_ids = self.pool.get('product.product').search( self.cr, self.uid, [('downpayment', '=', 'true')]) if not self.downpayments_ids: raise wizard.except_wizard('Error !', 'No down product defined') self.accounts = self.pool.get('account.analytic.account') #retrive info from the wizard open_only = False if 'form' in self.datas and 'open_only' in self.datas['form']: open_only = self.datas['form']['open_only'] supplier_too = False if 'form' in self.datas and 'supplier_too' in self.datas['form']: supplier_too = self.datas['form']['supplier_too'] #template doc = STPortraitTotalPage() doc.report_name = _("Indicator Report") #company name user = self.pool.get('res.users').browse(cr, uid, uid, context) doc.company_name = user.company_id.name story = [] #for each projects projects = self.accounts.browse(self.cr, self.uid, ids) for p in projects: #detail block builder = self._get_detail_builder(cr, context, p) story.append(builder.get_table()) #indicator block builder = self._get_indicator_builder(cr, context, p) story.append(Spacer(0, 8 * mm)) story.append(builder.get_table()) #downpayement block builder = self._get_downpayement_builder(cr, context, p) if builder != False: story.append(Spacer(0, 8 * mm)) story.append(builder.get_table()) #customer invoice builder = self._get_customer_invoice_builder( cr, context, p, open_only) #display the table only if there is lines in it if builder != False: story.append(Spacer(0, 8 * mm)) story.append(builder.get_table()) #supplier invoice if supplier_too: builder = self._get_supplier_invoice_builder( cr, context, p, open_only) #display the table only if there is lines in it if builder != False: story.append(Spacer(0, 8 * mm)) story.append(builder.get_table()) #start a new page for each projet story.append(PageBreak()) return doc.fillWith(story)
def _get_indicator_builder(self, cr, context, project): """ return the table that contain indicators """ builder = KeyValueTableBuilder(_("Indicators")) builder.add_key_column() builder.add_value_column() builder.add_key_column() builder.add_value_column() builder.add_key_cell(_("Theorical Revenue:")) amount = self.accounts._ca_theorical_calc( self.cr, self.uid, [project.id], "", {} )[project.id] currency = project.company_id.currency_id.name builder.add_money_cell(amount, currency) builder.add_key_cell(_("Hours Tot:")) hours = self.accounts._hours_quantity_calc( self.cr, self.uid, [project.id], "", {} )[project.id] builder.add_num_cell(hours) builder.add_key_cell(_("Invoiced Amount:")) amount = self.accounts._ca_invoiced_calc( self.cr, self.uid, [project.id], "", {} )[project.id] currency = project.company_id.currency_id.name builder.add_money_cell( amount, currency ) builder.add_key_cell(_("Invoiced Hours:")) hours = self.accounts._hours_qtt_invoiced_calc( self.cr, self.uid, [project.id], "", {} )[project.id] builder.add_num_cell(hours) builder.add_key_cell(_("Remaining Revenue:")) amount = self.accounts._remaining_ca_calc( self.cr, self.uid, [project.id], "", {} )[project.id] currency = project.company_id.currency_id.name builder.add_money_cell(amount, currency) builder.add_key_cell(_("Remaining Hours:")) hours = self.accounts._remaining_hours_calc( self.cr, self.uid, [project.id], "", {} )[project.id] builder.add_num_cell(hours) builder.add_key_cell(_("Uninvoiced Amount:")) amount = self.accounts._ca_to_invoice_calc( self.cr, self.uid, [project.id], "", {} )[project.id] currency = project.company_id.currency_id.name builder.add_money_cell(amount, currency) builder.add_key_cell(_("Uninvoiced Hours:")) hours = self.accounts._hours_qtt_non_invoiced_calc( self.cr, self.uid, [project.id], "", {} )[project.id] builder.add_num_cell(hours) builder.add_key_cell(_('Max Invoice Price:')) amount = project.amount_max currency = project.company_id.currency_id.name builder.add_money_cell(amount, currency) builder.add_key_cell(_('Maximal Hours:')) amount = project.quantity_max builder.add_num_cell(amount) builder.add_key_cell(_("Last Invoice Date:")) date = self.accounts._last_invoice_date_calc( self.cr, self.uid, [project.id], "", {} )[project.id] if date == "": date = None builder.add_date_cell(date) builder.add_key_cell(_("Last Invoiced Worked Date:")) date = self.accounts._last_worked_invoiced_date_calc( self.cr, self.uid, [project.id], "", {} )[project.id] if date == "": date = None builder.add_date_cell(date) builder.add_key_cell(_("Last Worked Date:")) date = self.accounts._last_worked_date_calc( self.cr, self.uid, [project.id], "", {} )[project.id] if date == "": date = None builder.add_date_cell(date) return builder
def create(self, cr, uid, ids, datas, context={}): """ construct the report """ #init self.cr = cr self.uid= uid self.datas = datas self.context = context self.pool = pooler.get_pool(self.cr.dbname) #get the is of products flagged as downpayment self.downpayments_ids = self.pool.get('product.product').search(self.cr, self.uid, [('downpayment', '=', 'true')]) if not self.downpayments_ids : raise wizard.except_wizard( 'Error !', 'No down product defined' ) self.accounts = self.pool.get('account.analytic.account') #retrive info from the wizard open_only = False if 'form' in self.datas and 'open_only' in self.datas['form']: open_only = self.datas['form']['open_only'] supplier_too = False if 'form' in self.datas and 'supplier_too' in self.datas['form']: supplier_too = self.datas['form']['supplier_too'] #template doc = STPortraitTotalPage() doc.report_name = _("Indicator Report") #company name user = self.pool.get('res.users').browse(cr,uid,uid, context) doc.company_name = user.company_id.name story = [] #for each projects projects = self.accounts.browse(self.cr, self.uid, ids) for p in projects: #detail block builder = self._get_detail_builder(cr, context, p) story.append(builder.get_table()) #indicator block builder = self._get_indicator_builder(cr, context, p) story.append(Spacer(0, 8*mm)) story.append(builder.get_table()) #downpayement block builder = self._get_downpayement_builder(cr, context, p) if builder != False: story.append(Spacer(0, 8*mm)) story.append(builder.get_table()) #customer invoice builder = self._get_customer_invoice_builder(cr, context, p, open_only) #display the table only if there is lines in it if builder != False: story.append(Spacer(0, 8*mm)) story.append(builder.get_table()) #supplier invoice if supplier_too: builder = self._get_supplier_invoice_builder(cr, context, p, open_only) #display the table only if there is lines in it if builder != False: story.append(Spacer(0, 8*mm)) story.append(builder.get_table()) #start a new page for each projet story.append(PageBreak()) return doc.fillWith(story)
def get_template_title(self, cr, context): """ return the title of the report """ return _("Versions Comparing")
def _get_indicator_builder(self, cr, context, project): """ return the table that contain indicators """ builder = KeyValueTableBuilder(_("Indicators")) builder.add_key_column() builder.add_value_column() builder.add_key_column() builder.add_value_column() builder.add_key_cell(_("Theorical Revenue:")) amount = self.accounts._ca_theorical_calc(self.cr, self.uid, [project.id], "", {})[project.id] currency = project.company_id.currency_id.name builder.add_money_cell(amount, currency) builder.add_key_cell(_("Hours Tot:")) hours = self.accounts._hours_quantity_calc(self.cr, self.uid, [project.id], "", {})[project.id] builder.add_num_cell(hours) builder.add_key_cell(_("Invoiced Amount:")) amount = self.accounts._ca_invoiced_calc(self.cr, self.uid, [project.id], "", {})[project.id] currency = project.company_id.currency_id.name builder.add_money_cell(amount, currency) builder.add_key_cell(_("Invoiced Hours:")) hours = self.accounts._hours_qtt_invoiced_calc(self.cr, self.uid, [project.id], "", {})[project.id] builder.add_num_cell(hours) builder.add_key_cell(_("Remaining Revenue:")) amount = self.accounts._remaining_ca_calc(self.cr, self.uid, [project.id], "", {})[project.id] currency = project.company_id.currency_id.name builder.add_money_cell(amount, currency) builder.add_key_cell(_("Remaining Hours:")) hours = self.accounts._remaining_hours_calc(self.cr, self.uid, [project.id], "", {})[project.id] builder.add_num_cell(hours) builder.add_key_cell(_("Uninvoiced Amount:")) amount = self.accounts._ca_to_invoice_calc(self.cr, self.uid, [project.id], "", {})[project.id] currency = project.company_id.currency_id.name builder.add_money_cell(amount, currency) builder.add_key_cell(_("Uninvoiced Hours:")) hours = self.accounts._hours_qtt_non_invoiced_calc( self.cr, self.uid, [project.id], "", {})[project.id] builder.add_num_cell(hours) builder.add_key_cell(_('Max Invoice Price:')) amount = project.amount_max currency = project.company_id.currency_id.name builder.add_money_cell(amount, currency) builder.add_key_cell(_('Maximal Hours:')) amount = project.quantity_max builder.add_num_cell(amount) builder.add_key_cell(_("Last Invoice Date:")) date = self.accounts._last_invoice_date_calc(self.cr, self.uid, [project.id], "", {})[project.id] if date == "": date = None builder.add_date_cell(date) builder.add_key_cell(_("Last Invoiced Worked Date:")) date = self.accounts._last_worked_invoiced_date_calc( self.cr, self.uid, [project.id], "", {})[project.id] if date == "": date = None builder.add_date_cell(date) builder.add_key_cell(_("Last Worked Date:")) date = self.accounts._last_worked_date_calc(self.cr, self.uid, [project.id], "", {})[project.id] if date == "": date = None builder.add_date_cell(date) return builder
class reminder(osv.osv): _name = "c2c_timesheet_reports.reminder" _description = "Handle the scheduling of messages" _columns = { 'reply_to': fields.char('Reply To', size=100), 'message': fields.text('Message'), 'subject': fields.char('Subject', size=200), } #default cron (the one created if missing) cron = { 'active': False, 'priority': 1, 'interval_number': 1, 'interval_type': 'weeks', 'nextcall': time.strftime("%Y-%m-%d %H:%M:%S", (datetime.today() + timedelta(days=1)).timetuple()), #tomorrow same time 'numbercall': -1, 'doall': True, 'model': 'c2c_timesheet_reports.reminder', 'function': 'run', 'args': '()', } #default message (the one created if missing) message = {'reply_to': '*****@*****.**'} def run(self, cr, uid): """ find the reminder recipients and send them an email """ #get all companies companies = self.pool.get('res.company').browse( cr, uid, self.pool.get('res.company').search(cr, uid, [])) #for each company, get all recipients recipients = [] for c in companies: recipients += self.get_recipients(cr, uid, {}, c) #get the message to send message_id = self.get_message_id(cr, uid, {}) message_data = self.browse(cr, uid, message_id) #send them email if they have an email defined emails = [] for r in recipients: if r.work_email: emails.append(r.work_email) if emails: tools.email_send(message_data.reply_to, [], message_data.subject, message_data.message, email_bcc=emails) def get_recipients(self, cr, uid, context, company): """return the list of users that must recieve the email """ #get the whole list of employees employees = self.compute_employees_list(cr, uid, context, company) #periods periods = self.compute_periods(company, time.gmtime(), 13) #remove the first one because it's the current one del periods[0] recipients = [] # for each employee for e in employees: #if the user still in the company? in_company = True if (e.started != False and e.started > time.strftime('%Y-%m-%d') ) or (e.ended != False and e.ended < time.strftime('%Y-%m-%d')): #do nothing... this user is not concerned anymore by timesheets pass else: #and for each periods for p_index in range(len(periods)): p = periods[p_index] status = self.compute_timesheet_status( cr, uid, context, company, e, p) # if there is a missing sheet or a draft sheet # and the user can receive alerts #then we must alert the user if status in ['Missing', 'Draft' ] and e.receive_timesheet_alerts: recipients.append(e) break # no need to go further for this user, he is now added in the list, go to the next one return recipients def compute_periods(self, company, date, periods_number=5): """ return the timeranges to display. This is the 5 last timesheets (depending on the timerange defined for the company) """ periods = [] (last_start_date, last_end_date) = self.get_last_period_dates(company, date) for cpt in range(periods_number): #find the delta between last_XXX_date to XXX_date if company.timesheet_range == 'month': delta = DateTime.RelativeDateTime(months=-cpt) elif company.timesheet_range == 'week': delta = DateTime.RelativeDateTime(weeks=-cpt) elif company.timesheet_range == 'year': delta = DateTime.RelativeDateTime(years=-cpt) start_date = last_start_date + delta end_date = last_end_date + delta periods.append((start_date, end_date)) return periods def get_last_period_dates(self, company, date): """ return the start date and end date of the last period to display """ # return the first day and last day of the month if company.timesheet_range == 'month': start_date = DateTime.Date(date.tm_year, date.tm_mon, 1) end_date = start_date + DateTime.RelativeDateTime(months=+1) #return the first and last days of the week elif company.timesheet_range == 'week': start_date = DateTime.Date( date.tm_year, date.tm_mon, date.tm_mday) + DateTime.RelativeDateTime( weekday=(DateTime.Monday, 0)) end_date = DateTime.Date(date.tm_year, date.tm_mon, date.tm_mday) + DateTime.RelativeDateTime( weekday=(DateTime.Sunday, 0)) # return the first and last days of the year elif company.timesheet_range == 'year': start_date = DateTime.Date(date.tm_year, 1, 1) end_date = DateTime.Date(date.tm_year, 12, 31) return (start_date, end_date) def compute_employees_list(self, cr, uid, context, company): """ return a dictionnary of lists of employees ids linked to the companies (param company) """ hr_employee_object = self.pool.get('hr.employee') employees = [] #employees associated with a Tinyerp user users_ids = self.pool.get('res.users').search( cr, uid, [('company_id', '=', company.id)], context=context) employees_users_ids = hr_employee_object.search( cr, uid, [('user_id', 'in', users_ids)]) #combine the two employees list, remove duplicates and order by name DESC employees_ids = hr_employee_object.search( cr, uid, [('id', 'in', employees_users_ids)], order="name ASC", context=context) return hr_employee_object.browse(cr, uid, employees_ids, context=context) def compute_timesheet_status(self, cr, uid, context, obj, employee, period): """ return the timesheet status for a user and a period """ status = 'Error' time_from = time.strptime(str(period[0]), "%Y-%m-%d %H:%M:%S.00") time_to = time.strptime(str(period[1]), "%Y-%m-%d %H:%M:%S.00") #if the starting date is defined and is greater than the date_to, it means the employee wasn't one at this period if employee.started != None and ( employee.started != False) and time.strptime( employee.started, "%Y-%m-%d") > time_to: status = 'Not in Company' #if the ending date is defined and is earlier than the date_from, it means the employee wasn't one at this period elif employee.ended != None and ( employee.ended != False) and time.strptime( employee.ended, "%Y-%m-%d") < time_from: status = 'Not in Company' #the employee was in the company at this period else: # does the timesheet exsists in db and what is its status? timeformat = "%Y-%m-%d" date_from = time.strftime(timeformat, time_from) date_to = time.strftime(timeformat, time_to) sheet = [] if employee.user_id.id != False: query = """SELECT state, date_from, date_to FROM hr_timesheet_sheet_sheet WHERE user_id = %s AND date_from >= '%s' AND date_to <= '%s' """ % (employee.user_id.id, date_from, date_to) cr.execute(query) sheets = cr.dictfetchall() #the tiemsheet does not exists in db if len(sheets) == 0: status = 'Missing' if len(sheets) > 0: status = 'Confirmed' for s in sheets: if s['state'] == 'draft': status = 'Draft' return status def get_cron_id(self, cr, uid, context): """return the reminder cron's id. Create one if the cron does not exists """ cron_id = 0 cron_obj = self.pool.get('ir.cron') try: #find the cron that send messages cron_id = cron_obj.search( cr, uid, [('function', 'ilike', self.cron['function']), ('model', 'ilike', self.cron['model'])], context={'active_test': False}) cron_id = int(cron_id[0]) except Exception, e: print e print 'warning cron not found one will be created' pass # ignore if the cron is missing cause we are going to create it in db #the cron does not exists if not cron_id: #translate self.cron['name'] = _('timesheet status reminder') cron_id = cron_obj.create(cr, uid, self.cron, context) return cron_id