Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

One2many through wizard, (without errors, but no add to the record)

By
Antonio Fernandez
on 2/3/16, 9:51 AM 357 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!


1

Jignesh Mehta

--Jignesh Mehta--
2087
| 6 4 8
Surat, India
--Jignesh Mehta--


Jignesh Mehta
On 2/3/16, 10:56 PM

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 ?

Solanki Shamji
on 2/4/16, 4:28 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/3/16, 9:51 AM
Seen: 357 times
Last updated: 2/3/16, 10:56 PM