Odoo Help

1

How can we create One2many field in a Transient Model ?(Many2One relationships from non-transient Model to TransientModel are forbidden)

By
Undan
on 2/21/17, 12:59 AM 212 views

While creating a One2many field we required  a inverse name (name of the inverse Many2one field in comodel_name) But Wizard records may refer to regular records or wizard records through many2one fields, but regular records cannot refer to wizard records through a many2one field!!!.

SO How can we create One2many field in a wizard.?

I have done like....

class sales_test_wizard(models.TransientModel):
    _name = 'sales.test.wizard'

    from_date = fields.Date(string="Date From") 
    to_date = fields.Date(string="Date To")  
    name =   fields.Char(string="Name", size=32, required=True)   
    sales_test_report = fields.One2many('sales.register', 'register_wiz_id', string='Sales Test')

class sales_register(models.Model):
    _name = 'sales.register'

    name = fields.Char('Order Reference')  
   date_order = fields.Datetime('Date') 
   partner_id = fields.Many2one('res.partner', 'Customer')
  amount_total = fields.Float(string='Total')
  register_wiz_id = fields.Many2one('sales.test.wizard','Register Wizard ID')


Am getting an error like : AssertionError: Many2One relationships from non-transient Model to TransientModel are forbidden

Can anyone please find me a solution for this...

0
Jainesh Shah
On 10/14/17, 5:39 AM

Hey Undan,

FYI, One2many fields are never stored in database so we use a Many2one relation which stores a reference of One2many field in the database.

Also, Transient Model is never stores the values of fields in the database. You cannot use a relationship by this way, Instead you should use both the models as Transient. (keeping a single view)

Hope this helps you.

Thanks!

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 2/21/17, 12:59 AM
Seen: 212 times
Last updated: 10/14/17, 5:39 AM