Hello everyone, i'm new to odoo developing and this is my first module.
I want to assign material resources to project task.(most of the time vehicles, we have many)
I want to know which cars are free and which ones are assigned to tasks.
So i created a boolean field named assigned to be True when a material resource is added to a task(i.e task_id is no more null), but it is always false when i check the database.So the function i created seems to not work for some reason.
from openerp import models, fields, api
class MaterialResource(models.Model):
_name = 'material.resource'
name = fields.Char('Material Resource', required=True)
description = fields.Selection(string='Description', selection=[('m', 'Mazda'), ('f', 'Ford')])
task_id = fields.Many2one("project.task", inverse_name="material_resource_ids")
assigned = fields.Boolean(compute="_get_material_status", store="True")
@api.one
@api.depends('task_id')
def _get_material_status(self):
if self.task_id is None:
return False
else:
return True
class TaskMaterial(models.Model):
_inherit = 'project.task'
material_resource_ids = fields.One2many(comodel_name="material.resource", inverse_name="task_id", string="Material Resource")