From 4da07d1f7b968dee1c5873769580f0c35295b916 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Tue, 29 Nov 2016 15:20:35 -0600 Subject: [PATCH] domain (#345) --- partner_contact_nutrition/README.rst | 2 +- partner_contact_nutrition/__openerp__.py | 4 +- .../models/res_partner.py | 45 +++++------ .../views/res_partner_view.xml | 74 +++++++++---------- 4 files changed, 63 insertions(+), 62 deletions(-) diff --git a/partner_contact_nutrition/README.rst b/partner_contact_nutrition/README.rst index 9c0d628e1..2319a04c0 100644 --- a/partner_contact_nutrition/README.rst +++ b/partner_contact_nutrition/README.rst @@ -20,7 +20,7 @@ To use this module, you need to: #. Go to Contacts #. Create or select a contact -#. In the Nutrition tab, enter its intake information +#. In the Nutrition tab, enter their intake information .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot diff --git a/partner_contact_nutrition/__openerp__.py b/partner_contact_nutrition/__openerp__.py index b40816ff5..16acd545e 100644 --- a/partner_contact_nutrition/__openerp__.py +++ b/partner_contact_nutrition/__openerp__.py @@ -4,8 +4,8 @@ { "name": "Partner Contact Nutrition Information", "summary": "Provide caloric intake", - "version": "9.0.1.0.0", - "category": "Uncategorized", + "version": "9.0.1.0.1", + "category": "Health", "website": "http://ursainfosystems.com", "author": "Ursa Information Systems, Odoo Community Association (OCA)", "license": "AGPL-3", diff --git a/partner_contact_nutrition/models/res_partner.py b/partner_contact_nutrition/models/res_partner.py index 710fafe43..837aa64d4 100644 --- a/partner_contact_nutrition/models/res_partner.py +++ b/partner_contact_nutrition/models/res_partner.py @@ -10,27 +10,30 @@ class ResPartner(models.Model): _inherit = 'res.partner' caloric_intake = fields.Float("Calories") - caloric_intake_uom = fields.Many2one("product.uom", "Calories UoM", - domain="[('category_id', '=', " - "self.env.ref('product_uom.\ - product_category_energy').id)]" - ) + caloric_intake_uom = fields.Many2one( + "product.uom", "Calories UoM", + domain=lambda self: [('category_id', '=', + self.env.ref( + 'product_uom.product_category_energy').id)] + ) carbohydrate_intake = fields.Float("Carbohydrate") - carbohydrate_intake_uom = fields.Many2one("product.uom", - "Carbohydrate UoM", - domain="[('category_id', '=', " - "self.env.ref('product.\ - product_uom_categ_kgm').id)]" # noqa - ) + carbohydrate_intake_uom = fields.Many2one( + "product.uom", "Carbohydrate UoM", + domain=lambda self: [('category_id', '=', + self.env.ref('product.product_uom_categ_kgm').id) + ] + ) fat_intake = fields.Float("Fat") - fat_intake_uom = fields.Many2one("product.uom", "Fat UoM", - domain="[('category_id', '=', " - "self.env.ref('product.\ - product_uom_categ_kgm').id)]" - ) + fat_intake_uom = fields.Many2one( + "product.uom", "Fat UoM", + domain=lambda self: [('category_id', '=', + self.env.ref('product.product_uom_categ_kgm').id) + ] + ) protein_intake = fields.Float("Protein") - protein_intake_uom = fields.Many2one("product.uom", "Protein UoM", - domain="[('category_id', '=', " - "self.env.ref('product.\ - product_uom_categ_kgm').id)]" - ) + protein_intake_uom = fields.Many2one( + "product.uom", "Protein UoM", + domain=lambda self: [('category_id', '=', + self.env.ref('product.product_uom_categ_kgm').id) + ] + ) diff --git a/partner_contact_nutrition/views/res_partner_view.xml b/partner_contact_nutrition/views/res_partner_view.xml index 694bb9020..f77e2211a 100644 --- a/partner_contact_nutrition/views/res_partner_view.xml +++ b/partner_contact_nutrition/views/res_partner_view.xml @@ -6,45 +6,43 @@ res.partner - - - - - - - + + + + + - - - + + + +