تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
4816 أدوات العرض

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!


الصورة الرمزية
إهمال
أفضل إجابة

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,


الصورة الرمزية
إهمال

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يونيو 24
442
1
سبتمبر 23
2160
2
سبتمبر 24
13265
2
أكتوبر 22
21272
0
سبتمبر 22
1893