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.

1

inherit create function in the new framework ?

By
Qamar Soft
on 9/8/14, 8:02 AM 4,901 views

I did:

    @api.model
    def create(self, cr, uid, vals, context=None):

 

 

Traceback (most recent call last):
  File "/opt/odoo/odoo-8.0/openerp/http.py", line 476, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/odoo-8.0/openerp/http.py", line 495, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/odoo-8.0/openerp/http.py", line 311, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/odoo-8.0/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo-8.0/openerp/http.py", line 308, in checked_call
    return self.endpoint(*a, **kw)
  File "/opt/odoo/odoo-8.0/openerp/http.py", line 685, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/odoo-8.0/openerp/http.py", line 360, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/odoo-8.0/addons/web/controllers/main.py", line 941, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/odoo-8.0/addons/web/controllers/main.py", line 933, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/opt/odoo/odoo-8.0/openerp/api.py", line 234, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-8.0/openerp/api.py", line 329, in old_api
    result = method(recs, *args, **kwargs)
TypeError: create() takes at least 4 arguments (2 given)

3

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 9/8/14, 8:21 AM

Hi,

Just do as like below.

@api.model
def create(self, vals, context=None):

then how can I call the cr and uid ?

Qamar Soft
on 9/8/14, 9:25 AM

You can find the cr and uid into self.env. Because this is the new api structure.

Emipro Technologies Pvt. Ltd.
on 9/8/14, 9:28 AM

If you get this as an answer then please accept this answer. And give me up vote. Thanks.

Emipro Technologies Pvt. Ltd.
on 9/8/14, 9:29 AM

I get this MissingError One of the documents you are trying to access has been deleted, please try again after refreshing. the create function has the line: new_id = super(res_partner, self).create( vals,)

Qamar Soft
on 9/8/14, 9:37 AM

Hello, For the calling of the create method you have two option. 1) As like normal calling with cr and uid. for that you can call new_id = super(res_partner,self).create(self.env.cr, self.env.uid, vals, context=context) 2) As like new API. For that you can call. new_id = super(res_partner,self).create(vals, context=context) Note : You have to confirm that here self is an recordset.

Emipro Technologies Pvt. Ltd.
on 9/8/14, 10:00 AM

I get the TypeError: create() takes exactly 2 arguments (5 given) when I use: new_id = super(res_partner,self).create(self.env.cr, self.env.uid, vals, context=context) AND TypeError: create() got an unexpected keyword argument 'context' WHEN USING new_id = super(res_partner,self).create(vals, context=context) I DIDN'T UNDERSTAND WHAT DO YOU MEAN WITH You have to confirm that here self is an recordset.

Qamar Soft
on 9/9/14, 6:07 AM

"self" have to be recordset (as like browse record) to call the new api. From the calling just remove the context argument.

Emipro Technologies Pvt. Ltd.
on 9/9/14, 6:19 AM

same problem :(

Qamar Soft
on 9/9/14, 7:19 AM

May I know that you are test into fresh database ?

Emipro Technologies Pvt. Ltd.
on 9/9/14, 7:21 AM

no it's not fresh I'm trying update all modules whit option -u all

Qamar Soft
on 9/9/14, 7:29 AM

Can you try it in fresh database ? Might be it is an error of some other module or may be issue of some data.

Emipro Technologies Pvt. Ltd.
on 9/9/14, 7:36 AM

I tryid in a different database but the same problem :(

Qamar Soft
on 9/12/14, 9:57 AM
2

Anil R. Kesariya

--Anil R. Kesariya--
4321
| 6 5 8
Gandhinagar, India
--Anil R. Kesariya--
ERP Consultant

Key Skill
-
Technical & Functional Expert
Anil R. Kesariya
On 9/9/14, 7:43 AM

Hello Rachid,

Here you go!

    @api.model
    def create(self, vals):
        cr, uid, context = self.env.args  #cursor , user and context can be fetch from env. if there is need of use.
        <Your code gose here...>
        res = super(<your model name>, self).create(vals)

      <Your code gose here...>
        return res

Hope this will helps you.

Anil.

 

0
Qamar Soft
On 9/9/14, 6:45 AM

I copied the same code of create function in the res_partner class HIERE IS

    @api.model
    def create(self, vals):
        if vals.get('website'):
            vals['website'] = self._clean_website(vals['website'])

        print vals

        partner = super(res_partner, self).create(vals)
        self._fields_sync(partner, vals)
        self._handle_first_contact_creation(partner)
        return partner

 

I get the same error One of the documents you are trying to access has been deleted, please try again after refreshing.

0
Nikunj Nakum
On 9/9/14, 6:50 AM

@api.model
@api.returns('self', lambda value: value.id)
 def create(self, vals):

 

no changes MissingError: ('MissingError', u'One of the documents you are trying to access has been deleted, please try again after refreshing.')

Qamar Soft
on 9/9/14, 6:56 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: 9/8/14, 8:02 AM
Seen: 4901 times
Last updated: 3/16/15, 8:10 AM