Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

[v15] How does one create an automated action (base.automation) via xml?

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
AutomatedActionsv15
1 Svar
11293 Visninger
Avatar
Mr Discovery

There's no documentation on creating an automated action.


The one there is, is about scheduled actions (ir.cron)

https://www.odoo.com/documentation/15.0/developer/reference/backend/actions.html#automated-actions-ir-cron


How does one create an automated action via XML?


It used to be something like this:

https://github.com/odoo/odoo/blob/12.0/addons/base_automation/data/base_automation_demo.xml


Bus this file doesn't exists after v12.


So the top entry gives this error in v15:


raise ParseError('while parsing %s:%s, somewhere inside\n%s' % (
odoo.tools.convert.ParseError: while parsing /home/odoo/src/user/module/views/automated_actions.xml:4, somewhere inside
<record id="test_rule_on_create" model="base.automation">
<field name="name">Base Automation: test rule on create</field>
<field name="model_id" ref="base_automation.model_base_automation_lead_test"/>
<field name="state">code</field>
<field name="code" eval="'records.write({\'user_id\': %s})' % ref('base.user_demo')"/>
<field name="trigger">on_create</field>
<field name="active" eval="True"/>
<field name="model_id" ref="base_automation.model_base_automation_lead_test"/>
<field name="filter_domain">[('state', '=', 'draft')]</field>
</record>





Any help would be appreciated.

0
Avatar
Kassér
Mohammed Amal N

try changing model_id to some other models like purchase.purchase_order. I guess odoo15 don't have this model
Also remove duplicate model_id field.

Mr Discovery
Forfatter

I did what you proposed, but to no avail.

I guess the problem is even before reading the contents, since it throws a parse error instead of complaining about the actual model.

It seems the XML isn't structured correctly or something.

Mr Discovery
Forfatter

Ok, I got it working now.

It was indeed being problematic about the external ID of the model.

I got more feedback in the log when I scrolled up in the server log, which was out of view on default.

Thank you for your help  Mohammed Amal N


Avatar
Mohammed Amal N
Bedste svar

Hi,

Make sure the references used to other models/ data in xml is available.

here is an example:



  

id="test_rule_on_create" model="base.automation">
name="name">Base Automation: test rule on create
name="model_id" ref="purchase.model_purchase_order"/>
name="state">code
name="code" eval="'records.write({\'user_id\': %s})' % ref('base.user_demo')"/>
name="trigger">on_create
name="active" eval="True"/>
name="filter_domain">[('state', '=', 'draft')]





Make sure you have purchase and base_automation modules in your dependencies. And demo data activated for the database for this code to work.

Thank You

0
Avatar
Kassér
Mohammed Amal N

<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="test_rule_on_create" model="base.automation">
<field name="name">Base Automation: test rule on create</field>
<field name="model_id" ref="purchase.model_purchase_order"/>
<field name="state">code</field>
<field name="code" eval="'records.write({\'user_id\': %s})' % ref('base.user_demo')"/>
<field name="trigger">on_create</field>
<field name="active" eval="True"/>
<field name="filter_domain">[('state', '=', 'draft')]</field>
</record>
</odoo>

Added code in comments as there is some problem for me to copy paste in here. don't know why

Mr Discovery
Forfatter

Even this throws a parse error:

<record id="test_rule_on_create" model="base.automation">
</record>

I think it bumps on the base.automation model. It probably doesn't work anymore to create records in this fashion.

Mohammed Amal N

I just tested this code myself in Odoo 15. Try the code in a new file. Your issue should be coming from some other place

Mr Discovery
Forfatter

and base_automation is in the depends section of the manifest

Mr Discovery
Forfatter

side question: do you happen to know how to populate the trigger_field_ids field?
I got so far as to provide something like this:
<field name="trigger_field_ids" eval="[(6, 0, [ ref('sale_subscription.date'), ref('module.x_studio_field')])]"/>

But it complains it can't find the external ID
ValueError: <class 'ValueError'>: "External ID not found in the system: sale_subscription.field_date" while evaluating

Mr Discovery
Forfatter

I found it: View Metadata after viewing the field in the model, there's the external ID you need to provide

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

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
How Can I Automatically Set Two Related Dates?
AutomatedActions v15
Avatar
0
mar. 22
3507
How to create alerts for expiration dates of products?
alerts AutomatedActions v15
Avatar
Avatar
Avatar
2
maj 24
3452
Problem with parasitic automated actions on products
products AutomatedActions v15
Avatar
Avatar
1
jan. 23
2425
How to obtain Product Category from Automated Action code Løst
python AutomatedActions v15
Avatar
Avatar
1
sep. 22
4713
Odoo 15: Automated action for send mail after specific days
sendmail AutomatedActions v15
Avatar
Avatar
1
jun. 22
4499
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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