diff --git a/addons/lunch/models/lunch_alert.py b/addons/lunch/models/lunch_alert.py index 93e0218631f..5a265f75f71 100644 --- a/addons/lunch/models/lunch_alert.py +++ b/addons/lunch/models/lunch_alert.py @@ -12,8 +12,9 @@ class LunchAlert(models.Model): given day, weekly or daily. The alert is displayed from start to end hour. """ _name = 'lunch.alert' _description = 'Lunch Alert' - _rec_name = 'message' + _order = 'write_date desc, id' + name = fields.Char(required=True) message = fields.Html('Message', required=True) until = fields.Date('Show Until') @@ -28,7 +29,7 @@ class LunchAlert(models.Model): available_today = fields.Boolean('Is Displayed Today', compute='_compute_available_today', search='_search_available_today') - active = fields.Boolean(default=True) + active = fields.Boolean('Active', default=True) location_ids = fields.Many2many('lunch.location', string='Location') diff --git a/addons/lunch/models/lunch_order.py b/addons/lunch/models/lunch_order.py index ba447ab394e..911b7315c46 100644 --- a/addons/lunch/models/lunch_order.py +++ b/addons/lunch/models/lunch_order.py @@ -51,7 +51,7 @@ class LunchOrder(models.Model): def _compute_display_toppings(self): for line in self: toppings = line.topping_ids_1 | line.topping_ids_2 | line.topping_ids_3 - line.display_toppings = '+ '.join(toppings.mapped('name')) + line.display_toppings = ' + '.join(toppings.mapped('name')) def update_quantity(self, increment): for line in self.filtered(lambda line: line.state != 'confirmed'): diff --git a/addons/lunch/models/lunch_product.py b/addons/lunch/models/lunch_product.py index 5623bce8de1..ea3306c3df4 100644 --- a/addons/lunch/models/lunch_product.py +++ b/addons/lunch/models/lunch_product.py @@ -15,24 +15,31 @@ class LunchProductCategory(models.Model): name = fields.Char('Product Category', required=True) company_id = fields.Many2one('res.company', default=lambda self: self.env.company_id) currency_id = fields.Many2one('res.currency', related='company_id.currency_id') - topping_label_1 = fields.Char('Topping Label 1', required=True, default='Supplements') - topping_label_2 = fields.Char('Topping Label 2', required=True, default='Beverages') - topping_label_3 = fields.Char('Topping Label 3', required=True, default='Topping Label 3') + topping_label_1 = fields.Char('Topping 1 Label', required=True, default='Supplements') + topping_label_2 = fields.Char('Topping 2 Label', required=True, default='Beverages') + topping_label_3 = fields.Char('Topping 3 Label', required=True, default='Topping Label 3') topping_ids_1 = fields.One2many('lunch.topping', 'category_id', domain=[('topping_category', '=', 1)], ondelete='cascade') topping_ids_2 = fields.One2many('lunch.topping', 'category_id', domain=[('topping_category', '=', 2)], ondelete='cascade') topping_ids_3 = fields.One2many('lunch.topping', 'category_id', domain=[('topping_category', '=', 3)], ondelete='cascade') topping_quantity_1 = fields.Selection([ ('0_more', 'None or More'), ('1_more', 'One or More'), - ('1', 'Only One')], default='0_more', required=True) + ('1', 'Only One')], 'Topping 1 Quantity', default='0_more', required=True) topping_quantity_2 = fields.Selection([ ('0_more', 'None or More'), ('1_more', 'One or More'), - ('1', 'Only One')], default='0_more', required=True) + ('1', 'Only One')], 'Topping 2 Quantity', default='0_more', required=True) topping_quantity_3 = fields.Selection([ ('0_more', 'None or More'), ('1_more', 'One or More'), - ('1', 'Only One')], default='0_more', required=True) + ('1', 'Only One')], 'Topping 3 Quantity', default='0_more', required=True) + product_count = fields.Integer(compute='_compute_product_count', help="The number of products related to this category") + + def _compute_product_count(self): + product_data = self.env['lunch.product'].read_group([('category_id', 'in', self.ids)], ['category_id'], ['category_id']) + data = {product['category_id'][0]: product['category_id_count'] for product in product_data} + for category in self: + category.product_count = data.get(category.id, 0) @api.model def create(self, vals): diff --git a/addons/lunch/models/lunch_supplier.py b/addons/lunch/models/lunch_supplier.py index f0ee44b853f..40842de88fb 100644 --- a/addons/lunch/models/lunch_supplier.py +++ b/addons/lunch/models/lunch_supplier.py @@ -50,9 +50,8 @@ class LunchSupplier(models.Model): country_id = fields.Many2one('res.country', related='partner_id.country_id', readonly=False) responsible_id = fields.Many2one('res.users', string="Responsible", domain=lambda self: [('groups_id', 'in', self.env.ref('lunch.group_lunch_manager').id)], - default=lambda self: self.env.user.partner_id, - help="The responsible is the person that will order lunch for everyone" - "It will be used as the 'from' when sending the automatic email") + default=lambda self: self.env.user, + help="The responsible is the person that will order lunch for everyone. It will be used as the 'from' when sending the automatic email.") send_by = fields.Selection([ ('phone', 'Phone'), diff --git a/addons/lunch/views/lunch_alert_views.xml b/addons/lunch/views/lunch_alert_views.xml index 034a39e8f91..12c43c00f2d 100644 --- a/addons/lunch/views/lunch_alert_views.xml +++ b/addons/lunch/views/lunch_alert_views.xml @@ -6,7 +6,9 @@ - + + + @@ -16,8 +18,9 @@ lunch.alert - - + + + @@ -36,6 +39,12 @@ options='{"terminology": "archive"}'/> +
+
@@ -65,5 +74,6 @@ tree,form + {'search_default_inactive': 1, 'search_default_active': 1} diff --git a/addons/lunch/views/lunch_location_views.xml b/addons/lunch/views/lunch_location_views.xml index 1a52393ab81..db9cd3af5a5 100644 --- a/addons/lunch/views/lunch_location_views.xml +++ b/addons/lunch/views/lunch_location_views.xml @@ -32,7 +32,7 @@ lunch.location.view.form lunch.location - + diff --git a/addons/lunch/views/lunch_product_views.xml b/addons/lunch/views/lunch_product_views.xml index e04e37e0878..04964c55c47 100644 --- a/addons/lunch/views/lunch_product_views.xml +++ b/addons/lunch/views/lunch_product_views.xml @@ -169,6 +169,20 @@ + + Products + lunch.product + tree,kanban,form + {'search_default_group_by_supplier': 1} + +

+ Create a new product for lunch +

+ A product is defined by its name, category, price and vendor. +

+
+
+ Product category Tree lunch.product.category @@ -185,6 +199,14 @@
+
+ +
- +