跳至內容
Odoo 選單
  • 登入
  • 免費試用
  • 應用程式
    財政
    • 會計
    • 發票
    • 開支報銷
    • 試算表 (BI)
    • 文件管理
    • 電子簽名
    銷售
    • 客戶關係
    • 銷售
    • POS 銷售點管理 - 零售
    • POS 銷售點管理 - 餐廳
    • 訂閱
    • 租賃
    網站
    • 網站製作
    • 電子商務
    • 網誌
    • 討論區
    • 線上客服
    • 網上學習
    供應鏈
    • 庫存
    • 製造管理
    • 產品生命周期
    • 採購
    • 保養維護
    • 品質管理
    人力資源
    • 員工管理
    • 招聘
    • 休假
    • 工作表現評核
    • 內部推薦
    • 車隊管理
    市場推廣
    • 社交媒體推廣
    • 電郵推廣
    • 短訊營銷
    • 活動
    • 自動化推廣
    • 網上調查
    服務
    • 專案管理
    • 工時管理
    • 外勤服務管理
    • 技術支援
    • 工作規劃
    • 預約管理
    生產力
    • 聊天
    • 批核
    • 物聯網
    • VoIP
    • 知識庫
    • WhatsApp
    第三方應用程式 Odoo Studio Odoo 雲端平台
  • 行業
    零售
    • 書店
    • 服裝店
    • 家具店
    • 食品雜貨店
    • 五金店
    • 玩具店
    餐飲及款待
    • 酒吧及酒館
    • 餐廳
    • 快餐
    • 賓館
    • 飲品分銷商
    • 酒店
    房地產
    • 地產代理公司
    • 建築師事務所
    • 建造業
    • 物業管理
    • 園藝
    • 業主聯會
    顧問服務
    • 會計公司
    • Odoo 合作夥伴
    • 市場推廣公司
    • 律師事務所
    • 人才招募
    • 審計及認證
    製造管理
    • 紡織
    • 金屬
    • 家具
    • 食品
    • 啤酒廠
    • 企業禮品
    保健與健身
    • 運動俱樂部
    • 眼鏡店
    • 健身中心
    • 健康從業人員
    • 藥房
    • 髮型屋
    技術行業
    • 雜工
    • IT 硬體與支援
    • 太陽能系統
    • 鞋匠
    • 清潔服務
    • 暖通空調服務
    其他
    • 非牟利組織
    • 環境保護機構
    • 廣告板租賃
    • 攝影服務
    • 自行車租賃
    • 軟體經銷商
    瀏覽所有行業
  • 社群
    學習
    • 教學影片
    • 使用說明
    • 認證
    • 培訓
    • 網誌
    • Podcast
    增強教學效能
    • 教育計劃
    • Scale Up! 商業遊戲
    • 到訪 Odoo
    取得軟件
    • 下載
    • 版本對照表
    • 版本說明
    合作
    • GitHub
    • 討論區
    • 活動
    • 翻譯
    • 成為合作夥伴
    • 合作夥伴服務
    • 登記你的會計服務公司
    獲取服務相關資料
    • 尋找合作夥伴
    • 尋找會計服務
    • 預約顧問諮詢
    • 安裝及推行服務
    • 客戶案例
    • 支援
    • 軟件升級
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    預約示範
  • 定價
  • 技術支援

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

  • 客戶關係
  • e-Commerce
  • 會計
  • 庫存
  • PoS
  • 專案管理
  • MRP
All apps
只限註冊用戶才可與社群互動。
所有帖文 人 獎章
標籤 (查看所有)
odoo accounting v14 pos v15
關於此討論區
只限註冊用戶才可與社群互動。
所有帖文 人 獎章
標籤 (查看所有)
odoo accounting v14 pos v15
關於此討論區
支援

Automatic action to set manufacturing order in status Done

訂閱

此帖文有活動時,接收通知

此問題已被標幟
manufacturingworkorderv14Lot/SN
6 回覆
8177 瀏覽次數
頭像
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
頭像
捨棄
頭像
Midhun M M
最佳答案

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
頭像
捨棄
Lars Aam
作者

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
作者

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

頭像
Robbie
最佳答案

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


0
頭像
捨棄
Lars Aam
作者

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.

頭像
Daniel Blanco
最佳答案
for r in records.filtered(lambda x: x.state == ‘to_close’):                  

r.button_mark_done()

    

0
頭像
捨棄
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
作者

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

頭像
Chris TRINGHAM
最佳答案

Have you tried using this Python Code:

records.action_button_mark_done()


0
頭像
捨棄
Lars Aam
作者

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
作者

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.

頭像
Jainesh Shah(Aktiv Software)
最佳答案

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
頭像
捨棄
Lars Aam
作者

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.

頭像
MUHAMMAD Imran
最佳答案

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
頭像
捨棄
Lars Aam
作者

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

Lars Aam
作者

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

喜歡這則討論?不要只閱讀,加入發表意見吧!

今天就建立帳戶,享受獨家功能,與我們精彩的社群互動!

註冊
相關帖文 回覆 瀏覽次數 活動
Odoo Allows Multiple work orders simultaneously... But we require to run in sequence. How do I do that?
manufacturing sequence workorder v14
頭像
0
9月 21
4475
Odoo 17.sh = How can I create and assign a whole group of operators to a Work Order in an MO? 已解決
manufacturing workorder
頭像
頭像
1
9月 24
3015
V16 Work Order Cancel undo
manufacturing workorder
頭像
頭像
1
8月 24
2876
Can I prevent a Work Order from starting if the materials / products are not available or have not yet been picked? 已解決
manufacturing workorder starting prevent v14
頭像
頭像
1
6月 23
6126
Missing finish steps (QA check) when adding components to Manufacturing order
manufacturing workorder v14 Lots QualityChecks
頭像
0
6月 23
2513
社群
  • 教學影片
  • 使用說明
  • 討論區
開源
  • 下載
  • GitHub
  • Runbot 測試環境
  • 翻譯
服務
  • odoo.sh 網頁寄存
  • 支援
  • 升級
  • 自訂功能開發
  • 教育及培訓
  • 尋找會計服務
  • 尋找合作夥伴
  • 成為合作夥伴
關於我們
  • 關於 Odoo 公司
  • 品牌資產
  • 聯絡我們
  • 招聘
  • 活動
  • Podcast
  • 網誌
  • 客戶
  • 法律 • 私隱政策
  • 安全性
الْعَرَبيّة 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 是一套開放源碼的商業管理系統,涵蓋你公司全部的營運需要,包括客戶關係管理(CRM)、電子商務、會計、庫存管理、POS(銷售點管理)、專案管理等應用程式。

Odoo 的獨特價值是非常簡單易用,同時將不同應用程式完美整合。

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