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

How to create many2one field ? I'm getting error --"Many2One relationships from non-transient Model to TransientModel are forbidden"

By
Anil Bhatt
on 1/16/15, 1:24 AM 623 views

I want to create a new table, here is my .py code file

import openerp.addons.decimal_precision as dp
from openerp import pooler
from openerp.osv import fields, osv
import time

class manifest_shipping(osv.Model):
    _name = "delivery.manifest.shipping"

    _description = 'Delivery manifest'
    _columns = {
        'manifest_number': fields.char('Manifest Number', size=20, required=True), 
        'manifest_status': fields.selection([('1', 'Open'),('0', 'Closed')], "Manifest Status"),
        'tracking_number': fields.char('Tracking Number', size=30, required=True),
        'reference_no': fields.char('Reference No', size=30, required=True),
        'invoice_no': fields.char('Invoice Number', size=30, required=True),
        'order_no': fields.char('Order Number', size=30, required=True),
        'created': fields.char('Created', size=15, required=True),
        'shipping_provider_name': fields.many2one('delivery.carrier',
                                        'Shipping Provider Name',
                                        required=True),
        'username': fields.many2one('res.users',
                                        'Username',
                                        required=True),
        'shipping_city': fields.char('Shipping City', size=10, required=True),                                
        'shipping_pincode': fields.char('Shipping pincode', size=10, required=True),                                
        'shipping_mobile': fields.char('Shipping mobile', size=15, required=True),                                
        'shipping_region': fields.many2one('res.country.state',
                                        'Shipping Region',
                                        required=True),                                
        'shipping_package_code': fields.char('Shipping Package Code', size=10, required=True),
        'shipping_package_type': fields.selection([('1', 'DEFAULT')], "Shipping Package Type"),
        'length': fields.integer('Length(mm)'),
        'width': fields.integer('Width(mm)'),
        'height': fields.integer('Height'),
        'no_of_products': fields.integer('No Of Products'),
        'no_of_boxes': fields.integer('No Of Boxes'),
        'weight': fields.integer('Weight(gm)'),
        'shipping_charges': fields.float('Shipping Charges', digits_compute=dp.get_precision('Product Unit of Measure')),
        'amount': fields.float('Amount', digits_compute=dp.get_precision('Product Unit of Measure')),
        'comments': fields.char('Comments', size=10),
        'shipping_method': fields.selection([('1', 'Online'),('2', 'COD')], "Shipping Method",required=True,),
        'updated': fields.char('Updated', size=10),
        'picking_id': fields.many2one('stock.picking', 'Stock picking out'),
    }
    
    _defaults = {
        "length": 0,
        "width": 0,
        "height": 0,
        "shipping_charges": 0,
    }

It gives me error on "picking_id" field. "Many2One relationships from non-transient Model to TransientModel are forbidden"

 

Kindly help me on this.

0
Katherine Zaoral
On 2/6/15, 8:59 AM

In Odoo documentation wizard section http://goo.gl/AwU2Yp you will find this text "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."

You have a regular record and that error is telling you that you are linking to a trasient model.

The weird thing here is that stock.picking is not trasient model (wizard) is a regular model. So please check the version of Odoo you are using and be secure that you are using an stable one.

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: 1/16/15, 1:24 AM
Seen: 623 times
Last updated: 3/16/15, 8:10 AM