0

I have a class order_order:

class order_order(osv.osv):

    _inherit = "sale.order"

    _columns = {
        'order_completed_date' : fields.char('Order Completed Date'),
        .
        .
        .
    }

Based on this SO post I wrote the following initializer:

def __init__(self, **kwargs):
    super(order_order, self).__init__(**kwargs)
    self.order_completed_date = order_completed_date
    .
    .
    .

I am trying to create an object as:

order_order.__new__(order_completed_date=order_completed_date, ...)

But I am getting the following error:

TypeError: __new__() got an unexpected keyword argument 'order_completed_date'

EDIT: Getting the same error with:

order_order(order_completed_date=order_completed_date, ...)

EDIT2: Full error:

Traceback (most recent call last):
  File "/home/nish/repos/stage/openerp/web/addons/web/http.py", line 292, in dispatch
    r = method(self, **self.params)
  File "/home/nish/repos/stage/openerp/web/addons/web/controllers/spree_api.py", line 118, in some_html
    order_order(order_completed_date=order_completed_date, order_id=order_id, product_id=product_id, product_name=product_name, size=size, product_cost_cp=product_cost_cp, product_cost_sp=product_cost_sp, product_cost_mrp=product_cost_mrp, product_creation_date=product_creation_date, product_taxon=product_taxon, user_email=user_email, user_name=user_name, user_address=user_address, user_city=user_city, city_zip_code=city_zip_code, user_state=user_state, user_country=user_country)
TypeError: __new__() got an unexpected keyword argument 'user_address'

What am I doing wrong? How can I correct the error?

1 Answer 1

2

__new__ is the type’s constructor, and you usually don’t want to use it like that ever. The normal way to create an object, that also includes calling its initializator is this:

order_order(order_completed_date=order_completed_date, ...)

So, just call the type; and the parameters of that call will be passed to the initializator.

Sign up to request clarification or add additional context in comments.

6 Comments

Do I need to make changes in the initializer of base class?
Can you show the full error message? The same error is unlikely (since you are no longer calling __new__ explicitely); but it’s possible that passing the keyword arguments to the base type. You should probably not pass the keyword arguments to the base’s __init__.
Well, in the file spree_api.py, on line 119, you are still calling order_order.__new__(…) instead of just order_order(…).
Sorry, I copied the old traceback. PLease can you have a look again. Even without new, I am getting the same error
Also tried super(order_order, self).__init__(). But same
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.