This question has been flagged
1 Reply
5864 Views

Hi everybody,

I would like to add a new field in the sale.py : Table sale_order. This field will link to an purchase _order. It is why I add this in the python code

class sale_order(osv.osv):
_name = "sale.order"
_inherit = ['mail.thread', 'ir.needaction_mixin']
_description = "Sales Order"
_track = {
    'state': {
        'sale.mt_order_confirmed': lambda self, cr, uid, obj, ctx=None: obj['state'] in ['manual', 'progress'],
        'sale.mt_order_sent': lambda self, cr, uid, obj, ctx=None: obj['state'] in ['sent'],
        'sale.mt_order_bat': lambda self, cr, uid, obj, ctx=None: obj['state'] in ['bat']
    },
}
 .  
 .
 .

_columns = {
    'name': fields.char('Order Reference', size=64, required=True,
        readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True),
    'shop_id': fields.many2one('sale.shop', 'Shop', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
      .
      .
      . 
    'link_Purchase': fields.many2one('purchase.order', 'Link Purchase'),
}

But it don't work. I have this error:

'NoneType' object has no attribute '_table'

Someone knows why please?

Thank you a lot

Avatar
Discard

Please link the whole file you have created. (I assume you have created a new module, and not injected directly your python code into the sale.py file...)

Author

Hi Yann. Thank you for your help. I injected my code directly on sale.py. I will try to create my own file but for the beginning I prefered use the sale.py. I edited my text to be more clear.

I don't know, perhaps you have something in your log file that can help us to solve this ?

Author Best Answer

Hi Yann,

I will send you my log file as soon as I will be at home. Btw, maybe I need to "import" the module purchase in my module "sale"?

Edit: The error:

2014-01-10 11:27:24,627 31732 ERROR Selverine openerp: Failed to initialize database Selverine. Traceback (most recent call last): File "/opt/openerp/openerp/cli/server.py", line 97, in preload_registry db, registry = openerp.pooler.get_db_and_pool(dbname,update_module=update_module) File "/opt/openerp/openerp/pooler.py", line 33, in get_db_and_pool registry = RegistryManager.get(db_name, force_demo, status, update_module) File "/opt/openerp/openerp/modules/registry.py", line 193, in get update_module) File "/opt/openerp/openerp/modules/registry.py", line 219, in new openerp.modules.load_modules(registry.db, force_demo, status, update_module) File "/opt/openerp/openerp/modules/loading.py", line 350, in load_modules force, status, report, loaded_modules, update_module) File "/opt/openerp/openerp/modules/loading.py", line 256, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "/opt/openerp/openerp/modules/loading.py", line 165, in load_module_graph init_module_models(cr, package.name, models) File "/opt/openerp/openerp/modules/module.py", line 374, in init_module_models result = obj._auto_init(cr, {'module': module_name}) File "/opt/openerp/openerp/osv/orm.py", line 3163, in _auto_init if dest_model._table != 'ir_actions': AttributeError: 'NoneType' object has no attribute '_table'

Thanks

Selverine

Avatar
Discard

No, not at all. I've been able to do the same thing you try to do with res.partner, without importing it.

Author

The same thing with me. I can link to res.partner but not to purchase.order...

Hi ! Your log file is unreadable. But I think your class modified returns None. Please check all your brackets, comas, ... Something in the sale_order class is probably wrong. If not, try to quote the line you've add, then restart. To make sure it's your line the problem.