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

Automatic action to set manufacturing order in status Done

Subscriure's

Get notified when there's activity on this post

This question has been flagged
manufacturingworkorderv14Lot/SN
6 Respostes
8110 Vistes
Avatar
Lars Aam

When we produce many lot numbers from work order tablet view, a new manufacturing order is created for every lot number when you press 'Mark As Done' in the tablet view.

The order with the lot number that is complete stays in status "To close", and you have to manually close the manufacturing order that also post product movements.

We want to avoid this extra manual step.  Create an automatic action that do this. 

I know how to create an automatic action, but I do not know coding.  So I need that line of Python code that execute this. 

There is a button in the form view of Manufacturing order and I can see it uses method 'button_mark_done'.   How do I write the python expression that execute thios from an automatic action.

A video of how we confirm orders is found here. Jumpt to 3 minutes to see how orders are closed

https://drive.google.com/open?id=1-iuukpnL9Z1-SgjmnF4Id4AmhBzTyF2I&authuser=larsaam34%40gmail.com&usp=drive_fs

0
Avatar
Descartar
Avatar
Midhun M M
Best Answer

Hello Lars,

I am not an expert in coding side, but please try the following.

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



Note: Cron will not work in case any of the records are not satisfying the condition to mark as done. For example, If lot/Serial number is enabled, but yet to generate, So in this case cron will throw a warning.. if all the to_close state records are satisfying all the condition to mark as done, then this cron will work without any issue.
0
Avatar
Descartar
Lars Aam
Autor

Thanks a lot. But I was hoping to run this as an automatic action on the current record.
My action looks like this, but does not process the current record that change status. So very to close to get what we need, but not quite there yet.

https://drive.google.com/file/d/10IUucQ0BV9VSLJnMbCnklTfQILxkSntr/view?usp=sharing

Lars Aam
Autor

A solution might be to run the schedule action like every 5 minutes.

Avatar
Robbie
Best Answer

see below. Use this every day. Ignore the MO Type = Parent field, that's custom. 


0
Avatar
Descartar
Lars Aam
Autor

Thank you for your answer. The code you use is exact the same as we have in the server action "Button Mark Done". I am not able to get it working in a automated action. Orders remain in status "To Close". Quite frustrating. We use V14.

Avatar
Daniel Blanco
Best Answer
for r in records.filtered(lambda x: x.state == ‘to_close’):                  

r.button_mark_done()

    

0
Avatar
Descartar
Daniel Blanco

I didn't check the button_mark_done() code but it seems is not calling wizards at all. So you can execute it over the record set. Nevertheless, with my approach, you can be sure that we don't call it from records of the record set that cannot be closed yet.

Lars Aam
Autor

This must also be run as a schedule action? For a scheduled action this code also works:
model.search([('state', '=', 'to_close')]).button_mark_done().

I was thinking an automatic action would be more efficient, since it only needs to be run, when a work order for is partly confirmed. It is not so freequent. Will be hours between every event. With a scheduled action it must be run like every 5 minutes to be OK for the flow.
But with an automatic action, triggered by Update of field State(mrp.production), it do not process the order that triggered the action.

Daniel Blanco

You can run from automatic action as well. Using model directly is correct, nevertheless searching the whole model does not allow you to pre select a dataset

Avatar
Chris TRINGHAM
Best Answer

Have you tried using this Python Code:

records.action_button_mark_done()


0
Avatar
Descartar
Lars Aam
Autor

Thank you Chris. But the result was a error:

Error:
Odoo Server Error

Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/home/odoo/src/odoo/odoo/http.py", line 685, in dispatch
result = self._call_function(**self.params)
File "/home/odoo/src/odoo/odoo/http.py", line 361, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/http.py", line 349, in checked_call
result = self.endpoint(*a, **kw)
File "/home/odoo/src/odoo/odoo/http.py", line 914, in __call__
return self.method(*args, **kw)
File "/home/odoo/src/odoo/odoo/http.py", line 533, in response_wrap
response = f(*args, **kw)
File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1392, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/home/odoo/src/user/3rdparty/printnode_base/controllers/main.py", line 50, in _call_kw
return super(DataSetProxy, self)._call_kw(model, method, args, kwargs)
File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1380, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/odoo/src/odoo/odoo/api.py", line 400, in call_kw
model.flush()
File "/home/odoo/src/odoo/odoo/models.py", line 5473, in flush
self.recompute()
File "/home/odoo/src/odoo/odoo/models.py", line 5932, in recompute
process(field)
File "/home/odoo/src/odoo/odoo/models.py", line 5916, in process
field.recompute(recs)
File "/home/odoo/src/odoo/odoo/fields.py", line 1155, in recompute
self.compute_value(recs)
File "/home/odoo/src/odoo/odoo/fields.py", line 1177, in compute_value
records._compute_field_value(self)
File "/home/odoo/src/odoo/odoo/models.py", line 4080, in _compute_field_value
field.compute(self)
File "/home/odoo/src/odoo/odoo/fields.py", line 555, in _compute_related
record[self.name] = self._process_related(value[self.related_field.name])
File "/home/odoo/src/odoo/odoo/models.py", line 5712, in __setitem__
return self._fields[key].__set__(self, value)
File "/home/odoo/src/odoo/odoo/fields.py", line 1109, in __set__
self.write(protected_records, value)
File "/home/odoo/src/odoo/odoo/fields.py", line 1588, in write
records.env['ir.translation']._set_ids(
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_translation.py", line 272, in _set_ids
self.sudo().create([{
File "<decorator-gen-58>", line 2, in create
File "/home/odoo/src/odoo/odoo/api.py", line 348, in _model_create_multi
return create(self, arg)
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_translation.py", line 564, in create
self.flush()
File "/home/odoo/src/odoo/odoo/models.py", line 5473, in flush
self.recompute()
File "/home/odoo/src/odoo/odoo/models.py", line 5932, in recompute
process(field)
File "/home/odoo/src/odoo/odoo/models.py", line 5916, in process
field.recompute(recs)
File "/home/odoo/src/odoo/odoo/fields.py", line 1155, in recompute
self.compute_value(recs)
File "/home/odoo/src/odoo/odoo/fields.py", line 1177, in compute_value
records._compute_field_value(self)
File "/home/odoo/src/odoo/addons/base_automation/models/base_automation.py", line 378, in _compute_field_value
_compute_field_value.origin(self, field)
File "/home/odoo/src/odoo/odoo/models.py", line 4080, in _compute_field_value
field.compute(self)
File "/home/odoo/src/odoo/odoo/fields.py", line 555, in _compute_related
record[self.name] = self._process_related(value[self.related_field.name])
File "/home/odoo/src/odoo/odoo/models.py", line 5703, in __getitem__
return self._fields[key].__get__(self, type(self))
File "/home/odoo/src/odoo/odoo/fields.py", line 969, in __get__
self.recompute(record)
File "/home/odoo/src/odoo/odoo/fields.py", line 1155, in recompute
self.compute_value(recs)
File "/home/odoo/src/odoo/odoo/fields.py", line 1177, in compute_value
records._compute_field_value(self)
File "/home/odoo/src/odoo/addons/base_automation/models/base_automation.py", line 382, in _compute_field_value
action._process(records, domain_post=domain_post)
File "/home/odoo/src/odoo/addons/base_automation/models/base_automation.py", line 274, in _process
raise e
File "/home/odoo/src/odoo/addons/base_automation/models/base_automation.py", line 271, in _process
action_server.sudo().with_context(**ctx).run()
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_actions.py", line 632, in run
res = runner(run_self, eval_context=eval_context)
File "/home/odoo/src/odoo/addons/website/models/ir_actions.py", line 61, in _run_action_code_multi
res = super(ServerAction, self)._run_action_code_multi(eval_context)
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_actions.py", line 501, in _run_action_code_multi
safe_eval(self.code.strip(), eval_context, mode="exec", nocopy=True) # nocopy allows to return 'action'
File "/home/odoo/src/odoo/odoo/tools/safe_eval.py", line 347, in safe_eval
raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr))
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/http.py", line 641, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/odoo/src/odoo/odoo/http.py", line 317, in _handle_exception
raise exception.with_traceback(None) from new_cause
ValueError: <class 'AttributeError'>: "'mrp.production' object has no attribute 'action_button_mark_done'" while evaluating
"# Available variables:\n# - env: Odoo Environment on which the action is triggered\n# - model: Odoo Model of the record on which the action is triggered; is a void recordset\n# - record: record on which the action is triggered; may be void\n# - records: recordset of all records on which the action is triggered in multi-mode; may be void\n# - time, datetime, dateutil, timezone: useful Python libraries\n# - float_compare: Odoo function to compare floats based on specific precisions\n# - log: log(message, level='info'): logging function to record debug information in ir.logging table\n# - UserError: Warning Exception to use with raise\n# To return an action, assign: action = {...\nrecords.action_button_mark_done()"

Lars Aam
Autor

Running a schedule action every 5 minutes works. And is also OK in our process. A short timelag is not an issue. But automatic action seems more logic.

Daniel Blanco

Chris, you cannot call action_button_mark_done because there is no python code with this method. Instead, there is a method button_mark_done() defined in the model that is callable.

Avatar
Jainesh Shah(Aktiv Software)
Best Answer

Hello Lars Aam,

You Can Create Automated Action to set manufacturing order in status Done.

Find Example in comment.

I hope you are doing well.

For Example -

- Create an Automated action by adding name, model (Production Order as per your requirement), trigger (update as per your requirement), trigger fields(Status), Before Update domain (State = "progress"), filter domain (Status = "to_close") and Action to do ( Execute several actions as per your requirement )

- In the Actions Notebook below add the server action "Mark as Done".

- So when the order will change its state from "progress" to "to_close" our server action ( Mark as Done ) will be Triggered, and your order will be in the Done State.

I hope this will help you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

0
Avatar
Descartar
Lars Aam
Autor

Thank you for your answer. This was in fact the first I tried, before posting this question. It does not work. Order is not processed.
Difficuilt to understand why.

What works is a scheduled action with the code:
model.search([('state', '=', 'to_close')]).button_mark_done()

We are running this every 5 minutes, and that is OK for the business.

Avatar
MUHAMMAD Imran
Best Answer

you can use the "Workflow" feature to set up automatic actions that change the status of a manufacturing order to "Done." Here are the general steps to set this up:

  1. Go to the "Manufacturing" module in Odoo and navigate to the "Manufacturing Orders" menu.

  2. Select the manufacturing order for which you want to set up the automatic action.

  3. Click on the "More" button and select "Workflow."

  4. In the "Workflow" menu, you can create a new workflow or edit an existing one.

  5. In the workflow, you can create a new "Transition" that changes the status of the manufacturing order from "In Progress" to "Done" when certain conditions are met.

  6. You can set up conditions for the transition by clicking on the "Conditions" button.

  7. In the conditions, you can set up triggers that automatically change the status of the manufacturing order to "Done" when certain actions are performed, such as when all the products have been produced or when the production is completed.

  8. Save the workflow and activate it.

Please note that these are general steps and the exact steps may vary depending on the version of Odoo you are using.

-1
Avatar
Descartar
Lars Aam
Autor

Thank you for your answer. Cannot find button "More" and Workflow. We run V14, so maybe that is for a later version.

Lars Aam
Autor

I cannot find a "More" button in a manufacturing order in Odoo16

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
Odoo Allows Multiple work orders simultaneously... But we require to run in sequence. How do I do that?
manufacturing sequence workorder v14
Avatar
0
de set. 21
4420
Odoo 17.sh = How can I create and assign a whole group of operators to a Work Order in an MO? Solved
manufacturing workorder
Avatar
Avatar
1
de set. 24
2978
V16 Work Order Cancel undo
manufacturing workorder
Avatar
Avatar
1
d’ag. 24
2835
Can I prevent a Work Order from starting if the materials / products are not available or have not yet been picked? Solved
manufacturing workorder starting prevent v14
Avatar
Avatar
1
de juny 23
6114
Missing finish steps (QA check) when adding components to Manufacturing order
manufacturing workorder v14 Lots QualityChecks
Avatar
0
de juny 23
2465
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