Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

Automated Action for Creating Work Order

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
workorderautomation
2 Antwoorden
1269 Weergaven
Avatar
James Gaspelin

Hi all!

I have multiple operators that utilize the shop floor app only, and sometimes they have to add in work/tasks that would be outside of normal planning.


I would like to add a dummy work order that they can access and record time/notes for when those occurrences do happen. I already have that set up.


Upon marking it complete, I would like to have an automated action repopulate another identical work order in it's place, but with a new number that would be next in sequence.


Assuming the "execute python code" function is necessary here. Is there someone that can help me out with the code to complete this?

TIA!

0
Avatar
Annuleer
James Gaspelin
Auteur

After some trial and error, I have come up with a working solution. Before, I was trying to add to the work order sequence, however, there is no sequence setup for a workorder as those are tied to the manufacturing order. The code below will creates a new MO based on defined variables

#set variables for new MO:
mo_vals = {
'product_id': 3765,
'qty_producing': 1.0,
'product_uom_id': 1,
'bom_id': 18
}
#create new MO based on variables above and will follow the existing sequence:
new_mo = env['mrp.production'].create(mo_vals)
#confirm the MO so it is available in the shop floor app:
new_mo.action_confirm()

Avatar
James Gaspelin
Auteur Beste antwoord

I am getting a forbidden opcode error when saving after copying your code in. Are there any other ways to do this, or a way to override the error? Also, I forgot to mention, I am on Odoo 18 if that makes a difference

0
Avatar
Annuleer
STAFFINSIDE

Hi, there are a few things you can try:

1- Security Constraints: Check if there are any specific security rules applied to the model that might prevent the copy() method from being executed. You may need to tweak access control or create a custom group to allow this operation.

2- Permission Issues: Make sure that the user or group running the automated action has the proper permissions to access and modify work orders. Sometimes these errors are related to insufficient access rights.

3- Alternative Solution with Scheduled Action:
If the execute python code method is not working, you could consider using a scheduled action to periodically check for completed dummy work orders and duplicate them with a new number.

Here’s an example of how you might implement this:
- Create a scheduled action that runs periodically (like every minute or hour).
- Check for work orders that are in the "done" state.
- For each completed work order, copy it, reset the fields, and assign a new sequence number.

Python code for the scheduled action:

workorders = self.env['mrp.workorder'].search([('state', '=', 'done'), ('production_id', '!=', False)])
for wo in workorders:
new_wo = wo.copy({
'state': 'ready',
'time_ids': [(5, 0, 0)],
'qty_produced': 0,
})
new_wo.name = self.env['ir.sequence'].next_by_code('mrp.workorder') or new_wo.name

This way, the scheduled action runs automatically without needing the "execute Python code" method within the automated action.

4- Override the Forbidden Opcode Error (if applicable):
If you believe the code should run as intended, you could try overriding the security rules for the specific field or action causing the issue. However, this could have security implications, so it's better to first test with less risky solutions like the scheduled action approach.

Let me know if any of these suggestions help.

James Gaspelin
Auteur

I do not believe it is a security or permission issue, but I have been working on an alternative solution. I am trying to create a new record by attaching the proper id to each mandatory field, however, I am not sure how to implement the next_by_code sequence as the production_id.
workorder_data = {
'name': 'Rework Cover',
'production_id':
'operation_id': 24,
'workcenter_id': 19,
'product_id': 18,
'product_uom_id': 1,
'qty_producing': 1.0,
'state':'ready'
}
new_workorder = env['mrp.workorder'].create(workorder_data)

This method does create a new workorder but there are other issues with it because it has the same work order number assigned as the previous. What can I do to add the sequence as production_id? or is that based on an existing work order?

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Beste antwoord

Hi,

You can solve this by creating an Automated Action on the Work Order (mrp.workorder) model with trigger On Update, and using the following Python code in the action:


if record.state == 'done' and record.production_id:

    new_wo = record.copy({

        'state': 'ready',

        'time_ids': [(5, 0, 0)],

        'qty_produced': 0,

    })

    new_wo.name = self.env['ir.sequence'].next_by_code('mrp.workorder') or new_wo.name


This will duplicate your dummy work order when marked done, reset it to ready, clear logs, and give it the next sequence number.


Hope it helps

0
Avatar
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
How to avoid non-literal domain
automation
Avatar
Avatar
Avatar
2
aug. 25
1575
Copy custom field when lead create contact and opportunity Opgelost
automation
Avatar
Avatar
Avatar
2
aug. 25
2474
Error: Automated action CRM/Discuss
automation
Avatar
0
feb. 25
2492
Setting automation rule based on date field
automation
Avatar
Avatar
1
aug. 25
3402
Automation rule to restrict close won
automation
Avatar
Avatar
2
dec. 24
2666
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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