Skip to Content
Menu
This question has been flagged
5429 Views

Hi,

I have many2one field 'date_id' in model 'make.situation' 

class MakeSituation(models.TransientModel):

_name = "make.situation"


date_id = fields.Many2one('due.dates', string="Due dates", domain="[('situation_id','=',active_id)]")
 in xml file: 

<field name="date_id" widget="selection" />
i want to show due dates available for the current project in selection format using the active id, but the domain restriction is not working it says: DataError: ERREUR: syntaxe en entrée invalide pour l'entier : « 2018-04-04 » LINE 1: ...".id FROM "due_dates" WHERE ("due_dates"."id" in ('2018-04-0...

i also tried with on_change function but i got the same error

@api.onchange('date_id')

def onchange_product_id(self):

active_id = self.env.context.get('active_ids', []) or []

proj_obj = self.env['project.task'].browse(active_id)

liste = []

for record in proj_obj:

for line in record.project_id.due_dates_id:

liste.append(line.due_date)

return {'domain':{'date_id':[('id','in',liste)]}}




class DueDates (models.Model):

_name = "due.dates"

due_date = fields.Date("Due dates")

project_id = fields.Many2one("project.project")

situation_id = fields.One2many('make.situation','date_id')


class ProjectProject(models.Model):

_inherit = "project.project

due_dates_id = fields.One2many('due.dates','project_id',string="Due Dates")

in project.project xml file i have : 

<page string="Due Dates">

<field name="due_dates_id">

<tree string="Due dates" editable="bottom">

<field name="due_date" string="Due Dates" required="True"/>

</tree>

</field>

</page>

Any suggestion please ?

Thanks








Avatar
Discard