Skip to Content
Menu
This question has been flagged

\

I am trying to programmatically create a new purchase order inside a model method invoked by a button.

I do this:

@api.multi
def do_create_purchase_order(self):
    purchase_order = self.env['purchase.order'].create()

But I get:

TypeError: create() takes exactly 2 arguments (1 given)

How can I get a new purchase order created?

Avatar
Discard
Best Answer

Hi,

Try by passing the values to the create method and see.

@api.multi
def do_create_purchase_order(self):
vals = {'field_1': 'value_1', 'field_2': 'value_2'}
purchase_order = self.env['purchase.order'].create(vals)

For creating records from code: Create Record From Code in Odoo


Thanks

Avatar
Discard
Author

I would mention that model's required fields without default values need to be added

Related Posts Replies Views Activity
1
Sep 18
3447
3
Dec 19
2062
0
Aug 17
2976
5
Apr 17
4610
1
Jan 22
13558