I have two models
class Management(models.Model):
_name = 'management.project'
line_impact_ids = fields.One2many('management.project.reference.impact', 'change_management_id')
class ManagementProductImpact(models.Model):
_name = 'management.project.reference.impact'
partner_id = fields.Many2one('res.partner', string="Client", required=True,)
project_id = fields.Many2one('project.project', string="Projet", required=True,)
change_management_id = fields.Many2one('sirail_change_management.project', string="Management",)
I defined a function to assign default values depends on line_impact_ids like this
class Management(models.Model):
_name = 'management.project'
line_impact_ids = fields.One2many('management.project.reference.impact', 'change_management_id')
@api.onchange('line_impact_ids')
def onchange_method(self):
result = self.env['management.project.reference.impact'].default_get(['partner_id', 'project_id'])
if self.line_impact_ids:
last = self.env['management.project.reference.impact'].search([])[-1]
result['partner_id'] = last.partner_id.id
result['project_id'] = last.project_id.id
does not work please can you help me and how should i use default_get in this case