This question has been flagged
1 Reply
3226 Views

Hi, I am a beginner and do not know that failure can have my code. I'm trying to pass a value from a field in the wizard to a field one2many from parent form. No errors, but it adds nothing. The function is called from a button at the wizard. Please, I need to know that in my code fails

Here is the code:

wizard_box.py

# -*- coding: utf-8 -*-
from openerp import models, fields, api
import openerp.exceptions
class wizard_box(models.TransientModel):
_name = 'test_am.wizard_box'
name = fields.Char(string="Box")
@api.one
    def assing_value(self):                                                                                             self.env['test_am.delivery_note'].write({'assing_box': (0, 0,{'name': 'self.name'})})

models.py

class test_am_delivery_note(models.Model):
_name = 'test_am.delivery_note'
assing_box = fields.One2many('test_am.box','name', 'Boxes')


Thanks for the help in advance!


Avatar
Discard
Best Answer

Hello Antonio,


Try below method.


@api.multi

def assign_value(self):

    test_obj = self.env['test_am.delivery_note'].browse(self._context.get('active_id'))

    for test in test_obj:

        self.name = test.name


Hope it works for you.

Thanks,


Avatar
Discard

can I use (self._context.get('active_id') if my record is not saved? or If I am creating new record ?