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

Trying to create a record in v8 but getting "old_api() takes at least 3 arguments (2 given)"

orm
By
Kit Sunde
on 8/25/14, 6:10 AM 3,278 views

I have a method schedule_emails that gets called via a server action. In it I'm trying to create an instance of sale.order_email.scheduled_email however it's raising an exceptin saying

old_api() takes at least 3 arguments (2 given)

Looking at openerp/api.py it seems like there's a wrapper that expects self.__dict__ to have a _ids attribute for it to call the new v8 api which presumably would work. It's not clear to me what I've failed to do, to call create on the model. My model:

class sales_order_email_field(osv.Model):
    _name = 'sale.order'
    _inherit = 'sale.order'
    _columns = {
        'email_chain': fields.many2one(
            'sale.order_email.collection',
            'Email Chain',
            required=False
        ),
        'scheduling_done': fields.boolean()
    }

    def schedule_emails(self):
        model = self.pool.get('sale.order_email.scheduled_email')
        model.create({
            'order_id': self.id,
            'send_at': datetime.utcnow(),
            'subject': 'Auto Test',
            'html_body': "HI"
        })

0
Kit Sunde
On 8/25/14, 6:12 AM

I was immitating what was being done in the sales.order model with regards to creating new records, but grepping around I noticed the accounts/account_invoice.py uses the newer api.

I needed to change:

model = self.pool.get('sale.order_email.scheduled_email')

into:

model = self.env['sale.order_email.scheduled_email']

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: 8/25/14, 6:10 AM
Seen: 3278 times
Last updated: 3/16/15, 8:10 AM