Hi Ammar,
In
Odoo, you can create an automation rule to automatically confirm an
order when a particular product is added to the order lines. Here's how
you can do it:
- Navigate to Automation: Go to Odoo technical settings and navigate to the Automation menu.
- Create a New Rule: Click on "Create" to create a new automation rule.
- Set the Trigger:
Choose the trigger for your automation rule. Since you want the rule to
be triggered when a new order line is created, select "When a record is
created" as the trigger.
- Define the Condition:
Define a condition that checks if the product added to the order line
matches the specific product. Click on "Add a condition" and set it to
check the product name of the order line.
- Define the Action:
Define the action to be taken when the condition is met. Click on "Add
an action" and select "Run Python Code" as the action type.
- Write Python Code: Write Python code to confirm the associated sale order if the condition is met. You can use the self.env object to access the Odoo environment and perform operations on the sale order.
Here's an example of Python code you can use:
if record.product_id.name == 'Your Specific Product Name':
record.order_id.action_confirm()
Replace 'Your Specific Product Name' with the name of your specific product.
- Save and Apply: Save the automation rule, and make sure to apply it to the appropriate model (e.g., Sale Order Line).
- Test:
Test the automation rule by adding the specific product to an order
line and verifying that the associated sale order is automatically
confirmed.
Please note that the exact steps and options available in Odoo may vary depending on your Odoo version and configuration.
Hope it helps
Maybe this would work:
for record in records:
record.order_id.action_confirm()