Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Automatic action to set manufacturing order in status Done

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
manufacturingworkorderv14Lot/SN
6 Respuestas
8146 Vistas
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
Mejor respuesta

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
Mejor respuesta

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
Mejor respuesta
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
Mejor respuesta

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)
Mejor respuesta

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
Mejor respuesta

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

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Odoo Allows Multiple work orders simultaneously... But we require to run in sequence. How do I do that?
manufacturing sequence workorder v14
Avatar
0
sept 21
4452
Odoo 17.sh = How can I create and assign a whole group of operators to a Work Order in an MO? Resuelto
manufacturing workorder
Avatar
Avatar
1
sept 24
2993
V16 Work Order Cancel undo
manufacturing workorder
Avatar
Avatar
1
ago 24
2863
Can I prevent a Work Order from starting if the materials / products are not available or have not yet been picked? Resuelto
manufacturing workorder starting prevent v14
Avatar
Avatar
1
jun 23
6120
Missing finish steps (QA check) when adding components to Manufacturing order
manufacturing workorder v14 Lots QualityChecks
Avatar
0
jun 23
2488
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

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