[IMP] lunch: improve onboarding

The lunch application works fine, but some usability points need to be
improved in order to have a smoother onboarding.

These include:
Making lunch location tree view editable, instead of having to use the form view
Auto filling partner details from vendor form
Fixing typos in various labels
Add a name field on lunch.alert instead of using the message as _rec_name
Adding a stat button on lunch category to see the associated products

Task 1942776

closes odoo/odoo#33091

Signed-off-by: Romain Libert (rli) <rli@odoo.com>
This commit is contained in:
Jinal Patel
2019-05-14 11:59:06 +00:00
committed by RomainLibert
parent f0c919e5eb
commit 5c22dffb7a
9 changed files with 58 additions and 19 deletions
+3 -2
View File
@@ -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')
+1 -1
View File
@@ -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'):
+13 -6
View File
@@ -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):
+2 -3
View File
@@ -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'),
+13 -3
View File
@@ -6,7 +6,9 @@
<field name="arch" type="xml">
<search string="Search">
<field name="message"/>
<filter name="inactive" string="Currently inactive" domain="[('available_today','=',False)]"/>
<filter name="inactive_today" string="Currently inactive" domain="[('available_today', '=', False)]"/>
<filter name="active" string="Active" domain="[('active', '=', True)]"/>
<filter name="inactive" string="Archived" domain="[('active', '=', False)]"/>
</search>
</field>
</record>
@@ -16,8 +18,9 @@
<field name="model">lunch.alert</field>
<field name="arch" type="xml">
<tree>
<field name="active"/>
<field name="message"/>
<field name="active" widget="boolean_toggle"/>
<field name="name"/>
<field name="message" invisible="1"/>
<field name="available_today"/>
</tree>
</field>
@@ -36,6 +39,12 @@
options='{"terminology": "archive"}'/>
</button>
</div>
<div class="oe_title" name="title">
<label for="name" class="oe_edit_only"/>
<h1>
<field name="name"/>
</h1>
</div>
<group>
<group>
<field name="location_ids" widget="many2many_tags"/>
@@ -65,5 +74,6 @@
<field name="search_view_id" ref="lunch_alert_view_search"/>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="lunch_alert_view_tree"/>
<field name="context">{'search_default_inactive': 1, 'search_default_active': 1}</field>
</record>
</odoo>
+1 -1
View File
@@ -32,7 +32,7 @@
<field name="name">lunch.location.view.form</field>
<field name="model">lunch.location</field>
<field name="arch" type="xml">
<tree>
<tree editable="bottom">
<field name="name"/>
<field name="address"/>
</tree>
+23 -1
View File
@@ -169,6 +169,20 @@
</field>
</record>
<record id="lunch_product_action_statbutton" model="ir.actions.act_window">
<field name="name">Products</field>
<field name="res_model">lunch.product</field>
<field name="view_mode">tree,kanban,form</field>
<field name="context">{'search_default_group_by_supplier': 1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new product for lunch
</p><p>
A product is defined by its name, category, price and vendor.
</p>
</field>
</record>
<record id="lunch_product_category_view_tree" model="ir.ui.view">
<field name="name">Product category Tree</field>
<field name="model">lunch.product.category</field>
@@ -185,6 +199,14 @@
<field name="arch" type="xml">
<form string="Product Categories Form">
<sheet>
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button" type="action" name="%(lunch.lunch_product_action_statbutton)d"
context="{'search_default_category_id': active_id,'default_category_id': active_id}"
attrs="{'invisible': [('product_count', '=', 0)]}"
icon="fa-cutlery">
<field string="Products" name="product_count" widget="statinfo"/>
</button>
</div>
<div class="oe_title">
<label for="name" class="oe-edit-only"/>
<h1>
@@ -272,7 +294,7 @@
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new lunch category
Create a new product category
</p><p>
Here you can access all categories for the lunch products.
</p>
+1 -1
View File
@@ -29,7 +29,7 @@
</div>
<group>
<group>
<field name="partner_id"/>
<field name="partner_id" context="{'default_is_company': True, 'default_city': city, 'default_name': name, 'default_street': street, 'default_street2': street2, 'default_state_id': state_id, 'default_zip': zip_code, 'default_country_id': country_id, 'default_phone': phone}"/>
<label for="street" string="Address"/>
<div class="o_address_format">
<field name="street" placeholder="Street..." class="o_address_street"/>
+1 -1
View File
@@ -7,7 +7,7 @@
<menuitem name="Configuration" parent="menu_lunch" id="menu_lunch_config" sequence="53" groups="group_lunch_manager"/>
<menuitem name="New Order" parent="menu_lunch_title" id="lunch_order_menu_form" action="lunch.lunch_product_action_order" sequence="1"/>
<menuitem name="Previous Orders" parent="menu_lunch_title" id="lunch_order_menu_tree" action="lunch_order_action" sequence="2"/>
<menuitem name="My Orders" parent="menu_lunch_title" id="lunch_order_menu_tree" action="lunch_order_action" sequence="2"/>
<menuitem name="My Lunch Account" parent="menu_lunch_title" id="lunch_cashmove_report_menu_form" action="lunch_cashmove_report_action_account" sequence="3"/>
<menuitem name="Today's Orders" parent="menu_lunch_admin" id="lunch_order_menu_by_supplier" action="lunch_order_action_by_supplier" />