bzr revid: api@openerp.com-20121102123508-i0d6kls4ip2zpbfp
This commit is contained in:
Arnaud Pineux 2012-11-02 13:35:08 +01:00
parent 5212e76c47
commit ae2e1c02eb
3 changed files with 50 additions and 37 deletions

View File

@ -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'),

View File

@ -30,7 +30,6 @@
<field name="name">Club</field>
<field name="category_id" eval="str(ref('categ_sandwich'))"/>
<field name="price">3.30</field>
<field name="active">True</field>
<field name="supplier" eval="str(ref('partner_coin_gourmand'))"/>
<field name="descrîption">Jambon, Fromage, Salade, Tomates, comcombres, oeufs</field>
</record>
@ -39,7 +38,6 @@
<field name="name">Le Campagnard</field>
<field name="category_id" eval="str(ref('categ_sandwich'))"/>
<field name="price">3.30</field>
<field name="active">True</field>
<field name="supplier" eval="str(ref('partner_coin_gourmand'))"/>
<field name="descrîption">Brie, Miel, Cerneaux de noix</field>
</record>
@ -48,7 +46,6 @@
<field name="name">Le Pâté Crème</field>
<field name="category_id" eval="str(ref('categ_sandwich'))"/>
<field name="price">2.50</field>
<field name="active">True</field>
<field name="supplier" eval="str(ref('partner_coin_gourmand'))"/>
<field name="descrîption"></field>
</record>
@ -57,7 +54,6 @@
<field name="name">Fromage Gouda</field>
<field name="category_id" eval="str(ref('categ_sandwich'))"/>
<field name="price">2.50</field>
<field name="active">True</field>
<field name="supplier" eval="str(ref('partner_coin_gourmand'))"/>
<field name="descrîption"></field>
</record>
@ -66,7 +62,6 @@
<field name="name">Poulet Curry</field>
<field name="category_id" eval="str(ref('categ_sandwich'))"/>
<field name="price">2.60</field>
<field name="active">True</field>
<field name="supplier" eval="str(ref('partner_coin_gourmand'))"/>
<field name="descrîption"></field>
</record>
@ -75,7 +70,6 @@
<field name="name">Pizza Margherita</field>
<field name="category_id" eval="str(ref('categ_pizza'))"/>
<field name="price">6.90</field>
<field name="active">True</field>
<field name="supplier" eval="str(ref('partner_pizza_inn'))"/>
<field name="descrîption">Tomates, Mozzarella</field>
</record>
@ -84,7 +78,6 @@
<field name="name">Pizza Italiana</field>
<field name="category_id" eval="str(ref('categ_pizza'))"/>
<field name="price">7.40</field>
<field name="active">True</field>
<field name="supplier" eval="str(ref('partner_pizza_inn'))"/>
<field name="descrîption">Tomates fraiches, Basilic, Mozzarella</field>
</record>
@ -93,7 +86,6 @@
<field name="name">Pâtes Bolognese</field>
<field name="category_id" eval="str(ref('categ_pasta'))"/>
<field name="price">7.70</field>
<field name="active">True</field>
<field name="supplier" eval="str(ref('partner_pizza_inn'))"/>
<field name="descrîption"></field>
</record>
@ -102,7 +94,6 @@
<field name="name">Pâtes Napoli</field>
<field name="category_id" eval="str(ref('categ_pasta'))"/>
<field name="price">7.70</field>
<field name="active">True</field>
<field name="supplier" eval="str(ref('partner_pizza_inn'))"/>
<field name="descrîption">Tomates, Basilic</field>
</record>
@ -182,7 +173,6 @@
<record model="lunch.alert" id="alert_1">
<field name="message">Lunch must be ordered before 10h30 am</field>
<field name="day">days</field>
<field name="lunch_active">t</field>
<field name="active_from">0</field>
<field name="active_to">0</field>
</record>

View File

@ -75,6 +75,7 @@
<field name='arch' type='xml'>
<search string="lunch orders">
<field name="date"/>
<field name="order_line_ids"/>
<filter name='is_mine' string="My Orders" domain="[('user_id','=',uid)]"/>
</search>
</field>
@ -111,7 +112,9 @@
Click to create a lunch order.
</p>
<p>
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.
</p>
</field>
</record>
@ -127,6 +130,7 @@
<field name="help" type="html">
<p>
Here you can see your cash moves.<br/>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.
</p>
</field>
</record>
@ -143,6 +147,11 @@
<p>
Here you can see today's orders grouped by suppliers.
</p>
<p>
- Click on the <img src="../../../web/static/src/img/icons/terp-call-start.png"/> to announce that the meal is ordered <br/>
- Click on the <img src="../../../web/static/src/img/icons/gtk-apply.png"/> to announce that the meal is received <br/>
- Click on the <img src="../../../web/static/src/img/icons/gtk-cancel.png"/> to announce that the meal isn't available
</p>
</field>
</record>
<menuitem name="Today's Orders by Supplier" parent="menu_lunch_admin" id="menu_lunch_order_by_supplier_form" action="action_lunch_order_by_supplier_form" />
@ -158,6 +167,11 @@
<p>
Here you can see every orders grouped by suppliers and by date.
</p>
<p>
- Click on the <img src="../../../web/static/src/img/icons/terp-call-start.png"/> to announce that the meal is ordered <br/>
- Click on the <img src="../../../web/static/src/img/icons/gtk-apply.png"/> to announce that the meal is received <br/>
- Click on the <img src="../../../web/static/src/img/icons/gtk-cancel.png"/> red X to announce that the meal isn't available
</p>
</field>
</record>
<menuitem name="Orders by Supplier" parent="menu_lunch_admin" id="menu_lunch_control_suppliers" action="action_lunch_control_suppliers" />
@ -261,7 +275,13 @@
</p>
<p>
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.
</p>
<p>
Example: <br/>
- Recurency: Everyday<br/>
- Time interval: from 00h00 am to 11h59 pm<br/>
- Message: "You must order before 10h30 am"
</p>
</field>
</record>
@ -356,7 +376,6 @@
<field name="supplier"/>
<field name="description"/>
<field name="price"/>
<field name="active"/>
</tree>
</field>
</record>
@ -375,7 +394,6 @@
<field name='category_id'/>
<field name='supplier'/>
<field name='price'/>
<field name='active'/>
</group>
<label for='description'/>
<field name='description'/>
@ -429,39 +447,43 @@
<field name="day"/>
<field name='active_from' widget='float_time'/>
<field name='active_to' widget='float_time'/>
<field name="lunch_active"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="alert_form_view">
<field name="name">alert tree</field>
<field name="name">alert form</field>
<field name="model">lunch.alert</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="alert tree" version="7.0">
<sheet>
<group col="4" string="Schedule Date">
<field name="day"/>
<field name='lunch_active'/>
<field name="specific" attrs="{'invisible': [('day','!=','specific')], 'required':[('day','=','specific')]}"/>
<group string="Schedule Date">
<group>
<field name="day"/>
<field name="specific" attrs="{'invisible': [('day','!=','specific')], 'required':[('day','=','specific')]}"/>
</group>
</group>
<group attrs="{'invisible': [('day','!=','week')]}" col="4">
<field name="monday"/>
<field name="tuesday"/>
<field name="wednesday"/>
<field name="thursday"/>
<field name="friday"/>
<field name="saturday"/>
<field name="sunday"/>
<group attrs="{'invisible': [('day','!=','week')]}">
<group>
<field name="monday"/>
<field name="tuesday"/>
<field name="wednesday"/>
<field name="thursday"/>
</group>
<group>
<field name="friday"/>
<field name="saturday"/>
<field name="sunday"/>
</group>
</group>
<group string="Schedule Hour">
<field name='active_from' widget='float_time'/>
<field name='active_to' widget='float_time'/>
</group>
<label for='message'/>
<field name='message' placeholder="Write the message you want to display during the defined period..."/>
<group string='Message'>
<field name='message' nolabel='1' placeholder="Write the message you want to display during the defined period..."/>
</group>
</sheet>
</form>