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

How to configure the scheduled action to automate the manufacturing orders from confirmed state to done state

Subscribe

Get notified when there's activity on this post

This question has been flagged
Manufacturing OrderAutomatedActionsscheduledactionodoo16features
3 Replies
6940 Views
Avatar
Zahra Naveed

here is a code i am using in the scheduled action this code run perfectly if i run this manually but it didnot work every min.

i am accessing the  mrp.production this module in the selection

orders = env['mrp.production'].search([('state', 'in', ['confirmed', 'to_close'])])


for order in orders:

​ order.write({

​ 'qty_producing': order.product_qty,

​ })

​ move_lines = order.move_raw_ids

​ for move in move_lines:

​ move.write({

​ 'quantity_done': move.product_uom_qty,

​ })

​

​ order.write({

​ 'state': 'done',

​ })


image of my settings​

https://drive.google.com/file/d/1Lh1XkGNDKr7WHBNM4ttE6NnqNk6bKx37/view?usp=sharing

0
Avatar
Discard
Avatar
Hamid Ahmadimoghaddam
Best Answer

Hi krakalien,

why are you using Scheduled Action? Why not Automated Action, if it's going to have impact on all confirmed or to_close manufactured orders?

check this out:


BG,

Hamid - bitigloo GmbH

1
Avatar
Discard
Zahra Naveed
Author

i used this method but it did not give any output nor error.

Hamid Ahmadimoghaddam

it's weird, because I tested it in different scenarios before posting it, and again now, it's working for me. To be on the safe side, make sure your scheduled action is not active, when you are doing this.

Zahra Naveed
Author

thanks its working for me as well i didn't see before you removed the first line of code.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

To run the scheduled action for every minute you can create an XML file to define the scheduled action. In this XML file, you'll specify the model, method, and cron expression for the scheduled action. For example,

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <!-- Scheduled Action Definition -->
        <record id="ir_cron_send_email" model="ir.cron">
            <field name="name">Send Email Every Minute</field>
            <field name="model_id" ref="model_mrp_production"/>
            <field name="state">code</field>
<field name="code">model.automate_mrp_order()</field>
<field name="interval_number">1</field>
<field name="interval_type">minutes</field>
            <field name="numbercall">-1</field>
            <field name="doall" eval="False"/>
            <field name="active" eval="True"/>
        </record>
    </data>
</odoo>


In this XML file, we define an ir.cron record with the necessary details for the scheduled action. It specifies the model (model_mrp_production), the Python method (model.automate_mrp_order()), and that it should run every minute (interval_number and interval_type).


And inside the python method you can define your code

def automate_mrp_order(self):

orders = env['mrp.production'].search([('state', 'in', ['confirmed', 'to_close'])])

for order in orders:

order.write({

'qty_producing': order.product_qty,

})

move_lines = order.move_raw_ids

for move in move_lines:

move.write({

'quantity_done': move.product_uom_qty,

})

order.write({

'state': 'done',

})


Refer this below blog to know more details about how to create a scheduled action

Scheduled Action


Hope it helps


0
Avatar
Discard
Zahra Naveed
Author

thank you but i cant access the backend code so cant write the xml code or .py code in the backend i am just using frontend to do this task.

Avatar
Lars Aam
Best Answer

I did this in V14. I wanted an automated action, but was not able to make it work.   SO I ended up witj a scheduled action running every 1 minute.

When you process 'Mark as Done', Odoo perform several actions in the background (as posting stock movements) as well as check that all is OK in the manufacturing order.  

The little pyhton code I have that calls the method is:

model.search([('state', '=', 'to_close')]).button_mark_done()

And it runs on Model production order (of course). 

0
Avatar
Discard
Hamid Ahmadimoghaddam

Hi Lars, the action of the button will not work when you need to force the consumption of the components, because in the standard way, in this case, Odoo will show a wizard to the user. I don' remember if we had the wizard in Odoo14 or not, but in the later versions, you can also check.

Lars Aam

As far as I can read from your code, you fill the consumed and produced qty = to planned. If you keep that part of the code and then runnteh action "button_mark_done" you should be able to process without raising the warning. But still keep tha checks Odoo have in this action.

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
Odoo16: where is Automated Actions in Technical menu Solved
AutomatedActions odoo16features
Avatar
Avatar
Avatar
Avatar
3
Oct 23
4226
Manufacturing Order: automated State change when adding Lot/Serial Number Solved
Manufacturing Order AutomatedActions
Avatar
1
Jan 23
3084
ValueError: <class 'psycopg2.ProgrammingError'>: "can't adapt type 'mail.activity.type'" Solved
activity AutomatedActions odoo16features
Avatar
1
Aug 23
3688
ValueError: [class 'psycopg2.ProgrammingError']: "can't adapt type 'ir.model'" while evaluating Solved
activity AutomatedActions odoo16features
Avatar
Avatar
1
Aug 23
4434
Is it possible to lock Serial Numbers on MOs before Validating? Solved
Manufacturing Order Lots/Serial odoo16features
Avatar
Avatar
1
Mar 23
3294
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