Help

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Manufacturing Order

Avatar
odoo
Avatar
Discard
2 Answers
0
Avatar
odoo
Best Answer

Setup in Odoo

  1. Go to Developer Mode (activate it if not already).
  2. Navigate to Technical > Automation > Automated Actions.
  3. Create a new Automated Action:
    • Model: Manufacturing Order (mrp.production)
    • Trigger: On Update or On Creation & Update (depending on use case)
    • Filter Domain (optional): You may filter on state = 'confirmed' or similar.
    • Action To Do: Execute Python Code

Python Code Example

Here’s the Python code that can be used in the automated action to prevent production if components are missing:

if record.state == 'confirmed':
    for move in record.move_raw_ids:
        if move.product_id.type == 'product' and move.product_uom_qty > move.reserved_availability:
            raise UserError(f"Not enough stock for component '{move.product_id.display_name}'.\n"
                            f"Required: {move.product_uom_qty}, Reserved: {move.reserved_availability}")

Avatar
Discard
0
Avatar
odoo
Best Answer

There is no need for custom Python code to achieve this.

You set this up on the Bill of Material. In the 'Miscellaneous' tab, under 'Manufacturing Readiness', set this to 'When all components are available'. This should also be the default setting on a BoM.

Avatar
Discard