Skip to Content
Menu
This question has been flagged
5 Replies
2149 Views

I'm making an automated action to check if reordering rules are created when the user creates/updates the product, and if not, a warning message should appear. But so far, without success. What is wrong with my automated action?

I can't post a picture here, so... the automated action is as follows:

Model: Product

Trigger Condition: On Creation and Update

Watched Fields: nbr_reordering_rules

Before Domain Update: All Records

Apply in: (All) Products -> (Any) Can be Purchased or Route Contains Purchase

Action to Perform: Execute Python Code

Python code: 

for record in records:

  raise Warning("No Reordering Rules are set for this product. Create Reordering Rules before saving.")

Avatar
Discard
Best Answer

I think you need to check for [["orderpoint_ids","=",False]] to get products without any Reordering Rules.  Using nbr_reordering_rules as a watched field won't work.

Something like this (you can add more conditions):


You can check how many records will be selected using the domain:


To see a list of the records, click on the grey button.

This should be the result:


Avatar
Discard
Author

Thanks for your comment, but i can only add it manually to the domain (i can't select it from the dropdown) and nothing happens.

I added screenshots

Author

Thank you so much for your help, and sorry i took so long to reply. But it's not working for me. It only works for 'On Creation'. But already have a script to create reordering rules "On Creation'.

I have it set like this:

Model: Product

Trigger Condition: On Update

Before Domain Update: All Records

Apply in: (All) Products -> ["&",["categ_id","=","Matéria Prima"],["orderpoint_ids","=",False]]

Action to Perform: Execute Python Code

Python code:

for record in records:

raise Warning("No Reordering Rules are set for this product. Create Reordering Rules before saving.")

What can be wrong?

I think categ_id should be the id. You have the name, so should be categ_id.name

Author

I think it's a bug. Thanks for your help. And btw, your site is most helpful. I just opted to install a module for this, and it's working now. Thanks!

Related Posts Replies Views Activity
0
May 24
324
1
Mar 24
289
1
Jun 24
651
1
Jan 24
409
1
Oct 22
1110