From 8641681400fb97ba33da4bf6d2cc5da0756ff370 Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Thu, 7 Jan 2016 10:53:32 +0100 Subject: [PATCH] [IMP] Lunch: Archive products Add a stat/toggle button on form view Add a stat/toggle action on tree view --- addons/lunch/models/lunch.py | 4 ++- addons/lunch/views/lunch_views.xml | 57 ++++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/addons/lunch/models/lunch.py b/addons/lunch/models/lunch.py index c0a194df053..2f22f69659e 100644 --- a/addons/lunch/models/lunch.py +++ b/addons/lunch/models/lunch.py @@ -17,7 +17,7 @@ class LunchOrder(models.Model): _order = 'date desc' def _default_previous_order_ids(self): - prev_order = self.env['lunch.order.line'].search([('user_id', '=', self.env.uid)], limit=20, order='id desc') + prev_order = self.env['lunch.order.line'].search([('user_id', '=', self.env.uid), ('product_id.active', '!=', False)], limit=20, order='id desc') # If we return return prev_order.ids, we will have duplicates (identical orders). # Therefore, this following part removes duplicates based on product_id and note. return { @@ -194,6 +194,7 @@ class LunchProduct(models.Model): description = fields.Text('Description') price = fields.Float('Price', digits=dp.get_precision('Account')) supplier = fields.Many2one('res.partner', 'Vendor') + active = fields.Boolean(default=True) class LunchProductCategory(models.Model): @@ -245,6 +246,7 @@ class LunchAlert(models.Model): sunday = fields.Boolean('Sunday') start_hour = fields.Float('Between', oldname='active_from', required=True, default=7) end_hour = fields.Float('And', oldname='active_to', required=True, default=23) + active = fields.Boolean(default=True) @api.multi def name_get(self): diff --git a/addons/lunch/views/lunch_views.xml b/addons/lunch/views/lunch_views.xml index 98ea2261b11..37d00d7fd05 100644 --- a/addons/lunch/views/lunch_views.xml +++ b/addons/lunch/views/lunch_views.xml @@ -83,6 +83,7 @@ + @@ -434,6 +435,25 @@ + + Archive/Unarchive + True + ir.actions.server + + code + self.toggle_active(cr, uid, context.get('active_ids', []), context=context) + + + + action_lunch_archive_product + + + action + + lunch.product + client_action_multi + + lunch.product.search @@ -447,6 +467,7 @@ + @@ -459,18 +480,27 @@
- + +
+ +
- - + + + + + + + + - - - - -
-
@@ -494,6 +524,13 @@ lunch.alert
+
+ +