mirror of
https://gitlab.com/sonalarora/tra_backend.git
synced 2026-01-25 17:31:36 +02:00
work on diet plan
This commit is contained in:
6
diet_template/models/__init__.py
Normal file
6
diet_template/models/__init__.py
Normal 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
|
||||
BIN
diet_template/models/__pycache__/__init__.cpython-36.pyc
Normal file
BIN
diet_template/models/__pycache__/__init__.cpython-36.pyc
Normal file
Binary file not shown.
BIN
diet_template/models/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
diet_template/models/__pycache__/__init__.cpython-37.pyc
Normal file
Binary file not shown.
BIN
diet_template/models/__pycache__/diet.cpython-36.pyc
Normal file
BIN
diet_template/models/__pycache__/diet.cpython-36.pyc
Normal file
Binary file not shown.
BIN
diet_template/models/__pycache__/diet.cpython-37.pyc
Normal file
BIN
diet_template/models/__pycache__/diet.cpython-37.pyc
Normal file
Binary file not shown.
BIN
diet_template/models/__pycache__/project.cpython-36.pyc
Normal file
BIN
diet_template/models/__pycache__/project.cpython-36.pyc
Normal file
Binary file not shown.
BIN
diet_template/models/__pycache__/project.cpython-37.pyc
Normal file
BIN
diet_template/models/__pycache__/project.cpython-37.pyc
Normal file
Binary file not shown.
BIN
diet_template/models/__pycache__/res_partner.cpython-36.pyc
Normal file
BIN
diet_template/models/__pycache__/res_partner.cpython-36.pyc
Normal file
Binary file not shown.
BIN
diet_template/models/__pycache__/res_partner.cpython-37.pyc
Normal file
BIN
diet_template/models/__pycache__/res_partner.cpython-37.pyc
Normal file
Binary file not shown.
BIN
diet_template/models/__pycache__/sale_order.cpython-36.pyc
Normal file
BIN
diet_template/models/__pycache__/sale_order.cpython-36.pyc
Normal file
Binary file not shown.
BIN
diet_template/models/__pycache__/sale_order.cpython-37.pyc
Normal file
BIN
diet_template/models/__pycache__/sale_order.cpython-37.pyc
Normal file
Binary file not shown.
47
diet_template/models/diet.py
Normal file
47
diet_template/models/diet.py
Normal 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')
|
||||
23
diet_template/models/project.py
Normal file
23
diet_template/models/project.py
Normal 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')
|
||||
18
diet_template/models/res_partner.py
Normal file
18
diet_template/models/res_partner.py
Normal 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)])
|
||||
15
diet_template/models/sale_order.py
Normal file
15
diet_template/models/sale_order.py
Normal 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
|
||||
Reference in New Issue
Block a user