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

Generate new sales order from custom module [Closed]

By
Sam
on 1/21/15, 10:41 AM 447 views

The Question has been closed for reason: duplicate question

by
Yenthe
on 01/21/2015 10:55:54

I have a cutom module that should create a new sale_order based on the values of my module.
Sale order is generated by the following code:

    @api.one
    def create_sale_order(self):
    vals = {
        'name': self.name,
        'state': 'invoice_exept',
        'date_order': self.date_order,
        'date_create': self.date_order,
        'date_confirm': self.date_confirm,
        'user_id': self.user_id,
        'partner_id': self.partner_id,
        'order_policy': 'manual'
    }

    res = self.env['sale.order'].create(vals)
    return res

 

I'm getting the following error:

 

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 525, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 562, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 302, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 299, in checked_call
    return self.endpoint(*a, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 791, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 395, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 953, in call_button
    action = self._call_kw(model, method, args, {})
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 941, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 393, in old_api
    result = new_api(recs, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 397, in new_api
    result = [method(rec, *args, **kwargs) for rec in self]
  File "/usr/lib/python2.7/dist-packages/openerp/addons/mopnex_erp/mopnex_workshop.py", line 193, in action_test
    res = self.env['sale.order'].create(vals)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 462, in new_api
    result = method(self._model, cr, uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/sale/sale.py", line 355, in create
    defaults = self.onchange_partner_id(cr, uid, [], vals['partner_id'], context=context)['value']
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/sale/sale.py", line 331, in onchange_partner_id
    addr = self.pool.get('res.partner').address_get(cr, uid, [part.id], ['delivery', 'invoice', 'contact'])
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/res/res_partner.py", line 750, in address_get
    if record.type in adr_pref and not result.get(record.type):
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 775, in __get__
    self.determine_value(record)
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 868, in determine_value
    record._prefetch_field(self)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 3178, in _prefetch_field
    result = records.read(list(fnames), load='_classic_write')
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 3123, in read
    self._read_from_database(stored)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 3235, in _read_from_database
    cr.execute(query, [tuple(sub_ids)] + rule_params)
  File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 158, in wrapper
    return f(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
  File "/usr/lib/python2.7/dist-packages/psycopg2/extensions.py", line 129, in getquoted
    pobjs = [adapt(o) for o in self._seq]
ProgrammingError: can't adapt type 'res.partner'

I know that not all the field values are transferred from my module, but the key problem is that sale_order cannot connect with res.partner

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/21/15, 10:41 AM
Seen: 447 times
Last updated: 3/16/15, 8:10 AM