Rational
I tried to use notification_mail, and I have been bloked on the trigger. My need is to send automatically a mail when my invoice is posted. It is really hard to configure it because :
- If the mode is time : the mail will be sent every 5 minutes
- If the mode is write : the mail will be sent for each modification, without any possibility to evaluate a condition on the modification
Proposition
I propose to remove the fields condition and replace it by two other fields:
- cron_domain : a pyson field to define the domain to use when the trigger is called by the cron
- write_condition : a char to eval a python condition with the values passed to the write method and the existing record record.state in [‘draft’, ‘validated’] and values.get(‘state’) == 'posted’
And the method eval should be also removed to be replaced by:
- get_cron_domain : return the decoded domain
- eval_write_condition : do a python safe eval with the record and the values come from the write method, because the record is not modified yet.
The method trigger_write_get_eligibles (from ModelStorage) needs to have the values in the parameters, to propagate it to eval_write_condition.
Future
- create_condition based on the values passed at the create method with his associated method
- delete_condition based on the existing record with his associated method