Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

V9 Automated Actions wrong number of arguments

Subscriure's

Get notified when there's activity on this post

This question has been flagged
automatedactionsv9
1 Respondre
3994 Vistes
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
Descartar
Avatar
Yurii Razumovskyi
Best Answer

Try use @api.model instead @api.multi

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

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

Registrar-se
Related Posts Respostes Vistes Activitat
Code automated actions for custom Sale Order sequences in Odoo 12
automated actions
Avatar
Avatar
1
de febr. 21
5442
Automated Actions : Created Product Name automatically and internal reference automatically
automated actions
Avatar
Avatar
3
de juny 20
5980
Automated actions - creating directories (v13)
automated actions
Avatar
0
de juny 20
3593
How to set automated action to inactive a user on cretin date ?
automated actions
Avatar
0
de febr. 16
4738
Warnings in automated actions
automated actions warning
Avatar
0
d’ag. 23
4677
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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