Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

V9 Automated Actions wrong number of arguments

Subscribe

Get notified when there's activity on this post

This question has been flagged
automatedactionsv9
1 Reply
3991 Views
Avatar
Matthew LeHew

I'm new to Odoo and looking at setting up an instance with custom modules for my golf business. I also just want to learn how to develop for this system. I have to confess that learning the API has been difficult with available documentation, as I can't tell what examples are for instances pre-8.0 and what are for instances after. I'm also not sure if the method decorators are only meant to be used when configuring an old api call to the new system, or if they should be used all the time.

This is a pretty simple task that I'm trying to accomplish. I want an automated action to run every day that looks at records from a table and creates new ones. There should be a record for every time slot two weeks in advance. The first time the job is run, it would create two weeks' worth of records. Each time after that, it should only be creating records for the 14th day out. 

In golf/data/data.xml, I have:

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data noupdate="1">
<record id="ir_cron_scheduler_slot_create" model="ir.cron">
<field name="name">Slot Creator</field>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="True" name="doall"/>
<field eval="'golf.slots'" name="model"/>
<field eval="'create_slots'" name="function"/>
</record>
</data>
</openerp>

In golf/models/models.py I have:

# -*- coding: utf-8 -*-
from openerp import models, fields, api
import datetime
import logging
_logger = logging.getLogger(__name__)
class Slot(models.Model):
_name = 'golf.slots'
name = fields.Char(string="Title", required=True)
slotDatetime = fields.Datetime(required=True)
status = fields.Char(string="Status", required=True)
def create_slots(self, cr, uid, content=None):
slots_obj=self.pool.get('golf.slots')
def dates():
start_date=datetime.date.today()
end_date=start_date + datetime.timedelta(14)
for n in range ((end_date-start_date).days+1):
yield start_date + datetime.timedelta(n)
def times():
start_time = datetime.datetime(2016, 1, 1, 8, 00)
end_time = start_time + datetime.timedelta(hours=11)
l=[]
while start_time <= end_time:
l.append(start_time)
start_time+=datetime.timedelta(minutes=10)
return l
for date in dates():
_logger.info('Mark')
if slots_obj.search_count(cr, uid, [('slotDatetime', '=', date)]) == 0:
for time in self.times():
year = date.strftime('%Y')
month = date.strftime('%m')
day = date.strftime('%d')
hour = time.strftime('%H')
minute= time.strftime('%M')
nameString = date.strftime('%Y-%m-%d') + ' ' + time.strftime('%H:%M')
nameDT = datetime.datetime(year, month, day, hour, minute)
slots_obj.create(cr, uid, {'name': nameString, 'slotDatetime': nameDT, 'status': 'Open'})
_logger.info('create ' + nameString)

The module installs without error, and when I activate developer mode the Automated Action shows up in the list. When I execute it manually, nothing appears to happen (no records are created) and the log shows the following in the traceback:

2016-06-16 17:17:14,325 1104 ERROR odooTest openerp.addons.base.ir.ir_cron: Call of self.pool.get('golf.slots').create_slots(cr, uid, *()) failed in Job 6
Traceback (most recent call last):
File "/opt/odoo/openerp/addons/base/ir/ir_cron.py", line 129, in _callback
getattr(model, method_name)(cr, uid, *args)
TypeError: create_slots() takes exactly 1 argument (3 given)

I have tried changing the create_slots() method to only take (self) as an argument, I've tried preceding it with the @api.multi decorator, and I still get the same error.

I know the code is ugly right now, but at this stage it's just a proof of concept that I can get the model to execute the method properly. Any suggestions on how to get this working would be greatly appreciated, thanks!

0
Avatar
Discard
Avatar
Yurii Razumovskyi
Best Answer

Try use @api.model instead @api.multi

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Code automated actions for custom Sale Order sequences in Odoo 12
automated actions
Avatar
Avatar
1
Feb 21
5441
Automated Actions : Created Product Name automatically and internal reference automatically
automated actions
Avatar
Avatar
3
Jun 20
5977
Automated actions - creating directories (v13)
automated actions
Avatar
0
Jun 20
3592
How to set automated action to inactive a user on cretin date ?
automated actions
Avatar
0
Feb 16
4738
Warnings in automated actions
automated actions warning
Avatar
0
Aug 23
4676
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now