コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
1776 ビュー

Hello Odoo,

I have created a rule to confirm sales orders that have the product type "Booking Fees". I have tried running it manually and it does work. However, it fails to work automatically for some reason. I am hosting on-premise so it should not delay.



アバター
破棄

Maybe this would work:

for record in records:
record.order_id.action_confirm()

最善の回答

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:

  1. Navigate to Automation: Go to Odoo technical settings and navigate to the Automation menu.
  2. Create a New Rule: Click on "Create" to create a new automation rule.
  3. 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.
  4. 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.
  5. 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.
  6. 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.

  1. Save and Apply: Save the automation rule, and make sure to apply it to the appropriate model (e.g., Sale Order Line).
  2. 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

アバター
破棄
関連投稿 返信 ビュー 活動
1
11月 24
178
1
2月 24
1957
2
5月 24
2382
2
7月 24
1516
1
1月 24
1388