work on diet plan

This commit is contained in:
sonal
2020-08-04 11:57:11 +05:30
parent 54472af83b
commit d32f648b75
61 changed files with 2858 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
# See LICENSE file for full copyright and licensing details.
from . import diet
from . import project
from . import sale_order
from . import res_partner

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,47 @@
# See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class DietList(models.Model):
"""New model for creating diet Task."""
_name = 'diet.list'
_description = 'Information of task,interval and food items in task.'
name = fields.Char('Name')
sequence = fields.Integer("Sequence")
diet_id = fields.Many2one('diet.master', 'Diet Line')
food_item_ids = fields.One2many('diet.plan.lines', 'diet_list_id', 'Food')
class DietMaster(models.Model):
"""Information about diet plan and task in the plan and total
days of task.
"""
_name = 'diet.master'
_description = 'Diet Master'
name = fields.Char("Goal")
diet_task_ids = fields.One2many('diet.list', 'diet_id', 'Diet')
total_days = fields.Integer(
compute="_compute_calculate_total_days",
string="Total Days Of Diet Plan")
diet_plan_ids = fields.Many2many('diet.list', 'master_list_rel',
'master_id', 'diet_list_id',
string="Diet Task")
@api.depends('diet_plan_ids')
def _compute_calculate_total_days(self):
"""Calculating total days of PLan."""
for diet_master_rec in self:
diet_master_rec.total_days = \
len(diet_master_rec.diet_plan_ids.ids)
class DietPlanLines(models.Model):
_inherit = 'diet.plan.lines'
diet_list_id = fields.Many2one('diet.list', 'project task list')
diet_plan_id = fields.Many2one('project.task', 'Diet plan in task')

View File

@@ -0,0 +1,23 @@
# See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class Project(models.Model):
"""Inherited Project model for creating diet project."""
_inherit = 'project.project'
product_id = fields.Many2one('product.product', string='Client Product')
type = fields.Selection([('workout', 'Workout'), ('diet', 'Diet')], 'Type')
class Task(models.Model):
"""Inherited Project Task model for creating diet project."""
_inherit = "project.task"
_order = 'schedule_date asc'
_description = 'Details of task in diet plan.'
diet_plan_ids = fields.One2many(
'diet.plan.lines', 'diet_plan_id', 'Diet Plan')

View File

@@ -0,0 +1,18 @@
# See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class ResPartner(models.Model):
_inherit = "res.partner"
member_diet_plan = fields.Integer(
string='Diet Plan',
compute='_compute_member_diet_plan'
)
def _compute_member_diet_plan(self):
for rec in self:
rec.member_diet_plan = \
self.env['project.project'].search_count(
[('partner_id', '=', rec.id)])

View File

@@ -0,0 +1,15 @@
# See LICENSE file for full copyright and licensing details.
from odoo import api, models
class SaleOrder(models.Model):
_inherit = 'sale.order'
@api.model
def create(self, values):
rec = super(SaleOrder, self).create(values)
if self._context.get("is_diet_sale"):
rec.action_confirm()
return rec