summaryrefslogtreecommitdiff
path: root/addons/lunch/models
diff options
context:
space:
mode:
authorParth Mehta <pme@odoo.com>2016-01-06 18:45:29 +0530
committerYannick Tivisse <yti@odoo.com>2016-03-10 10:18:17 +0100
commit54245deebda56a24f7a2b266cc93f72670f77eef (patch)
tree0d0d2dfc3ce1d705fb900b757767f6abdd049217 /addons/lunch/models
parent6db140d5d6f4bf6b9a0772ad75ceeb5721e773f0 (diff)
[IMP] lunch: view improvement of previous orders.
Purpose: 1/ In the lunch app, previous orders list: the products are not displayed. It is written X Records but you don't see the products name. Therefore the information is useless. 2/ It is dangerous to be able to delete a previous order that has been received (it changes the lunch account amount) What is done: In Previous Orders list : - The view should be based on the sales orders lines. In that case, each line = 1 product. - add a note column (between product and status) - add a user column (between status and total) - Rename Total into Price - If order.line status = ordered or received, it shouldn't be possible to delete it. An ir.rule has been added to achieve this. - An additional group access right check is made in the actions 'confirm' 'cancel' and 'order' because they can be called in batch under the Action button.
Diffstat (limited to 'addons/lunch/models')
-rw-r--r--addons/lunch/models/lunch.py33
1 files changed, 21 insertions, 12 deletions
diff --git a/addons/lunch/models/lunch.py b/addons/lunch/models/lunch.py
index 2f22f69659e..c4906072ad9 100644
--- a/addons/lunch/models/lunch.py
+++ b/addons/lunch/models/lunch.py
@@ -156,32 +156,41 @@ class LunchOrderLine(models.Model):
"""
The order_line is ordered to the vendor but isn't received yet
"""
- self.state = 'ordered'
+ if self.user_has_groups("lunch.group_lunch_manager"):
+ self.state = 'ordered'
+ else:
+ raise AccessError(_("Only your lunch manager processes the orders."))
@api.one
def confirm(self):
"""
confirm one or more order line, update order status and create new cashmove
"""
- if self.state != 'confirmed':
- values = {
- 'user_id': self.user_id.id,
- 'amount': -self.price,
- 'description': self.product_id.name,
- 'order_id': self.id,
- 'state': 'order',
- 'date': self.date,
- }
+ if self.user_has_groups("lunch.group_lunch_manager"):
+ if self.state != 'confirmed':
+ values = {
+ 'user_id': self.user_id.id,
+ 'amount': -self.price,
+ 'description': self.product_id.name,
+ 'order_id': self.id,
+ 'state': 'order',
+ 'date': self.date,
+ }
self.env['lunch.cashmove'].create(values)
self.state = 'confirmed'
+ else:
+ raise AccessError(_("Only your lunch manager sets the orders as received."))
@api.one
def cancel(self):
"""
cancel one or more order.line, update order status and unlink existing cashmoves
"""
- self.state = 'cancelled'
- self.cashmove.unlink()
+ if self.user_has_groups("lunch.group_lunch_manager"):
+ self.state = 'cancelled'
+ self.cashmove.unlink()
+ else:
+ raise AccessError(_("Only your lunch manager cancels the orders."))
class LunchProduct(models.Model):