[IMP] lunch : make field translatable.

Now we can translate name and description field in lunch.product object
and we want that translation in kanban view of 'lunch.product.report'.

So we set related field in 'lunch.product.report' and remove those fields
from init().

Due to related field it will affect on performace of lunch.product.report
kanban view loading.

Task-2068989
closes odoo/odoo#41206

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
nje-odoo
2019-12-31 12:17:26 +00:00
committed by Yannick Tivisse
parent 5b62f6e0b6
commit 92472fbf9c
3 changed files with 7 additions and 9 deletions
+2 -2
View File
@@ -19,8 +19,8 @@ class LunchAlert(models.Model):
_description = 'Lunch Alert'
_order = 'write_date desc, id'
name = fields.Char('Alert Name', required=True)
message = fields.Html('Message', required=True)
name = fields.Char('Alert Name', required=True, translate=True)
message = fields.Html('Message', required=True, translate=True)
mode = fields.Selection([
('alert', 'Alert in app'),
+3 -3
View File
@@ -12,7 +12,7 @@ class LunchProductCategory(models.Model):
_inherit = 'image.mixin'
_description = 'Lunch Product Category'
name = fields.Char('Product Category', required=True)
name = fields.Char('Product Category', required=True, translate=True)
company_id = fields.Many2one('res.company', default=lambda self: self.env.company)
currency_id = fields.Many2one('res.currency', related='company_id.currency_id')
topping_label_1 = fields.Char('Extra 1 Label', required=True, default='Extras')
@@ -89,9 +89,9 @@ class LunchProduct(models.Model):
_inherit = 'image.mixin'
_order = 'name'
name = fields.Char('Product Name', required=True)
name = fields.Char('Product Name', required=True, translate=True)
category_id = fields.Many2one('lunch.product.category', 'Product Category', required=True)
description = fields.Text('Description')
description = fields.Text('Description', translate=True)
price = fields.Float('Price', digits='Account', required=True)
supplier_id = fields.Many2one('lunch.supplier', 'Vendor', required=True)
active = fields.Boolean(default=True)
+2 -4
View File
@@ -13,9 +13,9 @@ class LunchProductReport(models.Model):
id = fields.Integer('ID')
product_id = fields.Many2one('lunch.product', 'Product')
name = fields.Char('Product Name')
name = fields.Char('Product Name', related='product_id.name')
category_id = fields.Many2one('lunch.product.category', 'Product Category')
description = fields.Text('Description')
description = fields.Text('Description', related='product_id.description')
price = fields.Float('Price')
supplier_id = fields.Many2one('lunch.supplier', 'Vendor')
company_id = fields.Many2one('res.company')
@@ -81,9 +81,7 @@ class LunchProductReport(models.Model):
SELECT
row_number() over (ORDER BY users.id,product.id) AS id,
product.id AS product_id,
product.name,
product.category_id,
product.description,
product.price,
product.supplier_id,
product.company_id,