diff --git a/addons/lunch/lunch.py b/addons/lunch/lunch.py index 5c58801c353..c44c2de163c 100644 --- a/addons/lunch/lunch.py +++ b/addons/lunch/lunch.py @@ -75,46 +75,73 @@ class lunch_order(osv.Model): result[order.id]=alert_msg return result + def check_day(self,alert): + today = datetime.now().isoweekday() + if today == 1: + if alert.monday == True: + return True + if today == 2: + if alert.tuesday == True: + return True + if today == 3: + if alert.wednesday == True: + return True + if today == 4: + if alert.thursday == True: + return True + if today == 5: + if alert.friday == True: + return True + if today == 6: + if alert.saturday == True: + return True + if today == 7: + if alert.sunday == True: + return True + return False + def _default_alerts_get(self,cr,uid,arg,context=None): alert_ref = self.pool.get('lunch.alert') - alert_ids = alert_ref.search(cr,uid,[],context=context) + alert_ids = alert_ref.search(cr,uid,[('active','=',True)],context=context) alert_msg="" for alert in alert_ref.browse(cr,uid,alert_ids,context=context): if alert : #there are alerts - if alert.active==True: - #the alert is active - if alert.day=='specific': - #the alert is only activated a specific day - if alert.specific==fields.datetime.now().split(' ')[0]: - print alert.specific - elif alert.day=='week': - #the alert is activated during some days of the week - continue - elif alert.day=='days': - #the alert is activated everyday - if alert.active_from==alert.active_to: - #the alert is executing all the day - alert_msg+=" * " + display = False + if alert.day=='specific': + #the alert is only activated a specific day + if alert.specific==fields.datetime.now().split(' ')[0]: + display = True + elif alert.day=='week': + #the alert is activated during some days of the week + display = self.check_day(alert) + elif alert.day=='days': + #the alert is activated everyday + display = True + #Check if we can display the alert + if display == True: + if alert.active_from==alert.active_to: + #the alert is executing all the day + alert_msg+="* " + alert_msg+=alert.message + alert_msg+='\n' + elif alert.active_from=from_alert.time() and mynow.time()<=to_alert.time(): + alert_msg+="* " alert_msg+=alert.message alert_msg+='\n' - elif alert.active_from=from_alert.time() and mynow.time()<=to_alert.time(): - alert_msg+="* " - alert_msg+=alert.message - alert_msg+='\n' return alert_msg def onchange_price(self,cr,uid,ids,products,context=None): @@ -132,24 +159,6 @@ class lunch_order(osv.Model): res = {'value':{'total':tot}} return res - def _default_product_get(self,cr,uid,args,context=None): - cr.execute('''SELECT lol.id, lol.date, lol.user_id, lol.product, lol.note, lol.price, lol.write_date FROM lunch_order_line AS lol ORDER BY write_date''') - res = cr.dictfetchall() - result = [] - i=0 - pref_ref = self.pool.get('lunch.preference') - for temp in res: - if i==20: - break - if temp['user_id'] == uid: - prod = self.pool.get('lunch.product').browse(cr, uid, temp['product']) - temp['product_name'] = prod.name - temp['date'] = temp['write_date'] - new_id = pref_ref.create(cr,uid,temp) - result.append(new_id) - i+=1 - return result - def create(self, cr, uid, values, context=None): pref_ref = self.pool.get('lunch.preference') pref_ids = pref_ref.search(cr,uid,[],context=context) @@ -190,7 +199,19 @@ class lunch_order(osv.Model): text="" for pref in pref_ref.browse(cr,uid,pref_ids,context): if pref['user_id'].id == uid: - print "*************TEST***************" + function_name = "add_preference_"+str(pref.id) + price_text = "Price: "+str(pref['price']) + text += (''' + +

''')+pref['product_name']+('''

+
+ ''')+price_text+(''' +
+