From ae2e1c02eb30ece233c1c1e4fededff8fefd78da Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Fri, 2 Nov 2012 13:35:08 +0100
Subject: [PATCH] Lunch
bzr revid: api@openerp.com-20121102123508-i0d6kls4ip2zpbfp
---
addons/lunch/lunch.py | 13 ++++----
addons/lunch/lunch_demo.xml | 10 ------
addons/lunch/lunch_view.xml | 64 +++++++++++++++++++++++++------------
3 files changed, 50 insertions(+), 37 deletions(-)
diff --git a/addons/lunch/lunch.py b/addons/lunch/lunch.py
index 03c40e081d5..bae47cadc16 100644
--- a/addons/lunch/lunch.py
+++ b/addons/lunch/lunch.py
@@ -113,7 +113,7 @@ class lunch_order(osv.Model):
def _default_alerts_get(self,cr,uid,arg,context=None):
""" get the alerts to display on the order form """
alert_ref = self.pool.get('lunch.alert')
- alert_ids = alert_ref.search(cr,uid,[('lunch_active','=',True)],context=context)
+ alert_ids = alert_ref.search(cr,uid,[],context=context)
alert_msg = []
for alert in alert_ref.browse(cr,uid,alert_ids,context=context):
if self.can_display_alert(alert):
@@ -270,7 +270,6 @@ class lunch_order_line(osv.Model):
def confirm(self,cr,uid,ids,context=None):
""" confirm one or more order line, update order status and create new cashmove """
cashmove_ref = self.pool.get('lunch.cashmove')
- orders_ref = self.pool.get('lunch.order')
for order_line in self.browse(cr,uid,ids,context=context):
if order_line.state!='confirmed':
new_id = cashmove_ref.create(cr,uid,{'user_id': order_line.user_id.id, 'amount':-order_line.price,'description':order_line.product_id.name, 'order_id':order_line.id, 'state':'order', 'date':order_line.date})
@@ -278,7 +277,11 @@ class lunch_order_line(osv.Model):
return self._update_order_lines(cr, uid, ids, context)
def _update_order_lines(self, cr, uid, ids, context=None):
- for order in set(self.browse(cr,uid,ids,context=context).order_id):
+ orders_ref = self.pool.get('lunch.order')
+ orders = []
+ for order_line in self.browse(cr,uid,ids,context=context):
+ orders.append(order_line.order_id)
+ for order in set(orders):
isconfirmed = True
for orderline in order.order_line_ids:
if orderline.state == 'new':
@@ -293,7 +296,6 @@ class lunch_order_line(osv.Model):
def cancel(self,cr,uid,ids,context=None):
""" confirm one or more order.line, update order status and create new cashmove """
cashmove_ref = self.pool.get('lunch.cashmove')
- orders_ref = self.pool.get('lunch.order')
for order_line in self.browse(cr,uid,ids,context=context):
self.write(cr,uid,[order_line.id],{'state':'cancelled'},context)
for cash in order_line.cashmove:
@@ -301,6 +303,7 @@ class lunch_order_line(osv.Model):
return self._update_order_lines(cr, uid, ids, context)
_columns = {
+ 'name' : fields.related('product_id','name',readonly=True),
'order_id' : fields.many2one('lunch.order','Order',ondelete='cascade'),
'product_id' : fields.many2one('lunch.product','Product',required=True),
'date' : fields.related('order_id','date',type='date', string="Date", readonly=True,store=True),
@@ -327,7 +330,6 @@ class lunch_product(osv.Model):
'category_id': fields.many2one('lunch.product.category', 'Category', required=True),
'description': fields.text('Description', size=256, required=False),
'price': fields.float('Price', digits=(16,2)),
- 'active': fields.boolean('Active'), #If this product isn't offered anymore, the active boolean is set to false. This will allow to keep trace of previous orders and cashmoves.
'supplier' : fields.many2one('res.partner', 'Supplier'),
}
@@ -363,7 +365,6 @@ class lunch_alert(osv.Model):
_description = 'lunch alert'
_columns = {
'message' : fields.text('Message',size=256, required=True),
- 'lunch_active' : fields.boolean('Active'),
'day' : fields.selection([('specific','Specific day'), ('week','Every Week'), ('days','Every Day')], string='Recurrency', required=True,select=True),
'specific' : fields.date('Day'),
'monday' : fields.boolean('Monday'),
diff --git a/addons/lunch/lunch_demo.xml b/addons/lunch/lunch_demo.xml
index 720848844b5..3caa0d1b81e 100644
--- a/addons/lunch/lunch_demo.xml
+++ b/addons/lunch/lunch_demo.xml
@@ -30,7 +30,6 @@
Club3.30
- TrueJambon, Fromage, Salade, Tomates, comcombres, oeufs
@@ -39,7 +38,6 @@
Le Campagnard3.30
- TrueBrie, Miel, Cerneaux de noix
@@ -48,7 +46,6 @@
Le Pâté Crème2.50
- True
@@ -57,7 +54,6 @@
Fromage Gouda2.50
- True
@@ -66,7 +62,6 @@
Poulet Curry2.60
- True
@@ -75,7 +70,6 @@
Pizza Margherita6.90
- TrueTomates, Mozzarella
@@ -84,7 +78,6 @@
Pizza Italiana7.40
- TrueTomates fraiches, Basilic, Mozzarella
@@ -93,7 +86,6 @@
Pâtes Bolognese7.70
- True
@@ -102,7 +94,6 @@
Pâtes Napoli7.70
- TrueTomates, Basilic
@@ -182,7 +173,6 @@
Lunch must be ordered before 10h30 amdays
- t00
diff --git a/addons/lunch/lunch_view.xml b/addons/lunch/lunch_view.xml
index c55e92e8b54..56382c03be8 100644
--- a/addons/lunch/lunch_view.xml
+++ b/addons/lunch/lunch_view.xml
@@ -75,6 +75,7 @@
+
@@ -111,7 +112,9 @@
Click to create a lunch order.
- Select your favorite meals for today's lunch.
+ A lunch order is defined by its user, date and order lines.
+ Each order line corresponds to a product, an additional note and a price.
+ Before selecting your order lines, don't forget to read the warnings displayed in the reddish area.
@@ -127,6 +130,7 @@
Here you can see your cash moves. A cash moves can be either an expense or a payment.
+ An expense is automatically created when an order is received while a payment is encoded by the manager.
@@ -143,6 +147,11 @@
Here you can see today's orders grouped by suppliers.
+
+ - Click on the to announce that the meal is ordered
+ - Click on the to announce that the meal is received
+ - Click on the to announce that the meal isn't available
+
@@ -158,6 +167,11 @@
Here you can see every orders grouped by suppliers and by date.
+
+ - Click on the to announce that the meal is ordered
+ - Click on the to announce that the meal is received
+ - Click on the red X to announce that the meal isn't available
+
@@ -261,7 +275,13 @@
Alerts are used to warn employee from possible issues concerning the lunch orders.
- To create a lunch alert you have to define its recurrency (A specific day of the year, every week or every day), the time interval during which the alert should be executed and the message to display.
+ To create a lunch alert you have to define its recurrency, the time interval during which the alert should be executed and the message to display.
+
+
+ Example:
+ - Recurency: Everyday
+ - Time interval: from 00h00 am to 11h59 pm
+ - Message: "You must order before 10h30 am"