Browse Source

domain (#345)

pull/349/head
Maxime Chambreuil 8 years ago
committed by Dave Lasley
parent
commit
4da07d1f7b
  1. 2
      partner_contact_nutrition/README.rst
  2. 4
      partner_contact_nutrition/__openerp__.py
  3. 37
      partner_contact_nutrition/models/res_partner.py
  4. 2
      partner_contact_nutrition/views/res_partner_view.xml

2
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

4
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",

37
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)
]
)

2
partner_contact_nutrition/views/res_partner_view.xml

@ -6,7 +6,6 @@
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//page[@name='sales_purchases']" position="before">
<page name="nutrition" string="Nutrition">
<group>
@ -44,7 +43,6 @@
</group>
</page>
</xpath>
</data>
</field>
</record>

Loading…
Cancel
Save