Discussion:
[Erp5-dev] TaskConstraint proposition
Mikolaj Antoszkiewicz
2008-05-16 17:18:47 UTC
Permalink
Hi All,

Since the Order_validateData script for task_workflow has been removed,
I propose a proper TaskConstraint replacement to verify task consistency
before confirmation, so that Task Report could be generated.

TaskLineCategoryExistence constraint class handles the more complicated
check for existence of specific category ('reference' in our case) on
all contained Task Lines.

There is no constraint on destination_decision, since I assume there
doesn't have to be a task assignor (and it's not compulsory for the Task
Report generation), but without it (and with destination not a
'Person'), the notifyAssignee script raises an Exception and stops Task
Report building.
I'm attaching two patches for the notifications scripts, which fix the
problem mentioned above.

Mikolaj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TaskLineCategoryExistence.py
Type: text/x-python
Size: 3563 bytes
Desc: not available
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080516/0b6fbb52/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TaskConstraint.py
Type: text/x-python
Size: 3573 bytes
Desc: not available
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080516/0b6fbb52/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TaskReport_notifyAssignee.xml.patch
Type: text/x-patch
Size: 3695 bytes
Desc: not available
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080516/0b6fbb52/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TaskReport_copyOrderPropertiesAndNotifyAssignee.xml.patch
Type: text/x-patch
Size: 5602 bytes
Desc: not available
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080516/0b6fbb52/attachment-0001.bin>
Romain Courteaud
2008-05-19 09:08:39 UTC
Permalink
Post by Mikolaj Antoszkiewicz
Hi All,
Hi Mikolaj,
Post by Mikolaj Antoszkiewicz
Since the Order_validateData script for task_workflow has been removed,
I propose a proper TaskConstraint replacement to verify task consistency
before confirmation, so that Task Report could be generated.
Thanks for your contribution.
Post by Mikolaj Antoszkiewicz
TaskLineCategoryExistence constraint class handles the more complicated
check for existence of specific category ('reference' in our case) on
all contained Task Lines.
I don't understand why such Constraint class is required.
It seems easier to configure a PropertySheet on the Task Line Level
which uses CategoryExistence constraint, isn't it?
Post by Mikolaj Antoszkiewicz
Index: TaskReport_notifyAssignee.xml
===================================================================
--- TaskReport_notifyAssignee.xml (revision 20916)
+++ TaskReport_notifyAssignee.xml (working copy)
@@ -65,15 +65,24 @@
</item>
<item>
<key> <string>_body</string> </key>
- <value> <string>packing_list = state_change[\'object\']\n
+ <value> <string>task_report = state_change[\'object\']\n
+from Products.ERP5Type.Message import Message\n
+T_ = lambda msg: Message(\'ui\', msg)\n
This T_ variable does not follow the ERP5 convention.
Can you please use N_ variable instead.
Post by Mikolaj Antoszkiewicz
Index: TaskReport_copyOrderPropertiesAndNotifyAssignee.xml
===================================================================
As your modifying this script, I think it could also be a good idea to
improve his name, by changing it to something like:
TaskReport_copyOrderPropertyAndNotifyAssignee or
TaskReport_copyOrderPropertyListAndNotifyAssignee.

Regards,
Romain
Mikolaj Antoszkiewicz
2008-05-19 10:43:01 UTC
Permalink
Post by Romain Courteaud
Post by Mikolaj Antoszkiewicz
Hi All,
Hi Mikolaj,
Post by Mikolaj Antoszkiewicz
Since the Order_validateData script for task_workflow has been removed,
I propose a proper TaskConstraint replacement to verify task consistency
before confirmation, so that Task Report could be generated.
Thanks for your contribution.
Post by Mikolaj Antoszkiewicz
TaskLineCategoryExistence constraint class handles the more complicated
check for existence of specific category ('reference' in our case) on
all contained Task Lines.
I don't understand why such Constraint class is required.
It seems easier to configure a PropertySheet on the Task Line Level
which uses CategoryExistence constraint, isn't it?
And check each line's consistency on the workflow script level, right?
That is in the script that conducts consistency check for the Task.
Post by Romain Courteaud
Post by Mikolaj Antoszkiewicz
Index: TaskReport_notifyAssignee.xml
===================================================================
--- TaskReport_notifyAssignee.xml (revision 20916)
+++ TaskReport_notifyAssignee.xml (working copy)
@@ -65,15 +65,24 @@
</item>
<item>
<key> <string>_body</string> </key>
- <value> <string>packing_list = state_change[\'object\']\n
+ <value> <string>task_report = state_change[\'object\']\n
+from Products.ERP5Type.Message import Message\n
+T_ = lambda msg: Message(\'ui\', msg)\n
This T_ variable does not follow the ERP5 convention.
Can you please use N_ variable instead.
Well, I used T which was to mean T(ranslate), and I couldn't find the
convention about that.
Why N_ then?
Post by Romain Courteaud
Post by Mikolaj Antoszkiewicz
Index: TaskReport_copyOrderPropertiesAndNotifyAssignee.xml
===================================================================
As your modifying this script, I think it could also be a good idea to
TaskReport_copyOrderPropertyAndNotifyAssignee or
TaskReport_copyOrderPropertyListAndNotifyAssignee.
Ahh, right, sorry I missed that in such a looong name :)
I'll supply the newly-named version for replacement along with other
corrections.

Best regards,
Mikolaj
Romain Courteaud
2008-05-19 16:21:37 UTC
Permalink
Post by Mikolaj Antoszkiewicz
Post by Romain Courteaud
I don't understand why such Constraint class is required.
It seems easier to configure a PropertySheet on the Task Line Level
which uses CategoryExistence constraint, isn't it?
And check each line's consistency on the workflow script level, right?
That is in the script that conducts consistency check for the Task.
The checkConsistency method is called automatically on Task Lines.
Post by Mikolaj Antoszkiewicz
Well, I used T which was to mean T(ranslate), and I couldn't find the
convention about that.
Why N_ then?
Because of:
http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromEntireSystemAsPot.xml
But, as Jean-Paul said, it is better to use 'translateString' variable.

Regards,
Romain
Mikolaj Antoszkiewicz
2008-05-20 08:31:09 UTC
Permalink
Post by Romain Courteaud
Post by Mikolaj Antoszkiewicz
Post by Romain Courteaud
I don't understand why such Constraint class is required.
It seems easier to configure a PropertySheet on the Task Line Level
which uses CategoryExistence constraint, isn't it?
And check each line's consistency on the workflow script level, right?
That is in the script that conducts consistency check for the Task.
The checkConsistency method is called automatically on Task Lines.
Post by Mikolaj Antoszkiewicz
Well, I used T which was to mean T(ranslate), and I couldn't find the
convention about that.
Why N_ then?
http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromEntireSystemAsPot.xml
But, as Jean-Paul said, it is better to use 'translateString' variable.
Yes, especially that translateString's output is a string and Message
function outputs Message class instance which is un-decodable by the
email module methods.
But I was wondering why N_? What does it stand for?

Mikolaj
Jérome Perrin
2008-05-20 17:07:42 UTC
Permalink
Post by Mikolaj Antoszkiewicz
But I was wondering why N_? What does it stand for?
It's GNU gettext convention, originally:

_ is a macro to gettext (ie. the translate function)

N_ is a no-op macro, meaning that this message is not translated here
but is still marked as a translatable string, and tools such as xgettext
or yusei's script uses those markers to extract strings and produce .po
files.

Until today I misunderstood N_, and used it in ERP5 code where _ is
usually used.

J?rome
Jean-Paul Smets
2008-05-19 12:14:21 UTC
Permalink
Post by Romain Courteaud
This T_ variable does not follow the ERP5 convention.
Can you please use N_ variable instead.
Or, better, use
translateString

I personnally disagree with the name N_ (which is used in various parts)
and I still do not understand why we can not follow the normal
convention for it.

Regards,

JPS.
--
Jean-Paul Smets-Solanes, Nexedi CEO - Tel. +33(0)6 62 05 76 14
ERP5 Enterprise: Free / Open Source ERP for Critical Applications
http://www.erp5.com
ERP5 Express: Hosted Open Source ERP for small companies
http://www.myerp5.com
Nexedi: Consulting and Development of Free / Open Source Software
http://www.nexedi.com
Mikolaj Antoszkiewicz
2008-05-21 12:19:10 UTC
Permalink
Post by Romain Courteaud
Post by Mikolaj Antoszkiewicz
TaskLineCategoryExistence constraint class handles the more complicated
check for existence of specific category ('reference' in our case) on
all contained Task Lines.
I don't understand why such Constraint class is required.
It seems easier to configure a PropertySheet on the Task Line Level
which uses CategoryExistence constraint, isn't it?
Ok, Somehow I missed the fact that lines get consistency check along
with parent object.
But now I'm attaching the two fixed Constraint Property Sheets.

Mikolaj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TaskConstraint.py
Type: text/x-python
Size: 3224 bytes
Desc: not available
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080521/f5a9cd39/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TaskLineConstraint.py
Type: text/x-python
Size: 1803 bytes
Desc: not available
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080521/f5a9cd39/attachment-0001.py>
Loading...