Commit d3a337e3 authored by Jérome Perrin's avatar Jérome Perrin

2008-08-06 jerome

* Change Movement_getPriceCalculationOperandDict to use source_section / destination_section instead of source / destination.
* Change Movement_getPriceCalculationOperandDict to give priority to supply lines contained in related trade conditions.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22910 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c2b24956
...@@ -65,39 +65,70 @@ ...@@ -65,39 +65,70 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>def sourceSortMethod(a, b):\n <value> <string>def sourceSectionSortMethod(a, b):\n
if a.getSource():\n if a.getSourceSection():\n
return -1 # a defines a source and wins\n return -1 # a defines a source section and wins\n
return 1 # a defines no source ans loses\n return 1 # a defines no source section and loses\n
\n \n
def destinationSortMethod(a, b):\n \n
if a.getDestination():\n def destinationSectionSortMethod(a, b):\n
return -1 # a defines a destination and wins\n if a.getDestinationSection():\n
return 1 # a defines no destination ans loses\n return -1 # a defines a destination section and wins\n
\n return 1 # a defines no destination section and loses\n
def resourcePurchasePriceSortMethod(a, b):\n \n
if "Purchase" in a.getPortalType():\n \n
if "Purchase" in b.getPortalType():\n def getResourcePurchasePriceSortMethod(high_priority_supply_line_list):\n
return sourceSortMethod(a, b)\n def resourcePurchasePriceSortMethod(a, b):\n
else:\n if a in high_priority_supply_line_list:\n
return -1\n return -1\n
else:\n elif b in high_priority_supply_line_list:\n
if "Purchase" in b.getPortalType():\n
return 1\n return 1\n
else:\n
return destinationSortMethod(a, b)\n
\n \n
def resourceSalePriceSortMethod(a, b):\n if "Purchase" in a.getPortalType():\n
if "Sale" in a.getPortalType():\n if "Purchase" in b.getPortalType():\n
if "Sale" in b.getPortalType():\n return sourceSectionSortMethod(a, b)\n
return destinationSortMethod(a, b)\n else:\n
return -1\n
else:\n else:\n
if "Purchase" in b.getPortalType():\n
return 1\n
else:\n
return destinationSectionSortMethod(a, b)\n
return resourcePurchasePriceSortMethod\n
\n
\n
def getResourceSalePriceSortMethod(high_priority_supply_line_list):\n
def resourceSalePriceSortMethod(a, b):\n
if a in high_priority_supply_line_list:\n
return -1\n return -1\n
else:\n elif b in high_priority_supply_line_list:\n
if "Sale" in b.getPortalType():\n
return 1\n return 1\n
\n
if "Sale" in a.getPortalType():\n
if "Sale" in b.getPortalType():\n
return destinationSectionSortMethod(a, b)\n
else:\n
return -1\n
else:\n else:\n
return sourceSortMethod(a, b)\n if "Sale" in b.getPortalType():\n
return 1\n
else:\n
return sourceSectionSortMethod(a, b)\n
return resourceSalePriceSortMethod\n
\n
\n
def getRelatedTradeConditionList(trade_condition):\n
"""Get all trade conditions related to an order.\n
trade_condition parameter can be a trade condition or an order/invoice\n
"""\n
related_trade_condition_list = trade_condition.getSpecialiseValueList(\n
portal_type=(\'Sale Trade Condition\', \'Purchase Trade Condition\'))\n
for related_trade_condition in trade_condition.getSpecialiseValueList(\n
portal_type=(\'Sale Trade Condition\', \'Purchase Trade Condition\')):\n
related_trade_condition_list.extend(\n
getRelatedTradeConditionList(related_trade_condition))\n
return related_trade_condition_list\n
\n
\n \n
try:\n try:\n
explanation = context.getExplanationValue()\n explanation = context.getExplanationValue()\n
...@@ -107,16 +138,31 @@ except AttributeError:\n ...@@ -107,16 +138,31 @@ except AttributeError:\n
\n \n
if explanation is not None:\n if explanation is not None:\n
explanation_type = explanation.getPortalType()\n explanation_type = explanation.getPortalType()\n
high_priority_supply_line_list = []\n
if explanation_type in context.getPortalInvoiceTypeList() +\\\n
context.getPortalOrderTypeList():\n
# if there are trade conditions containing supply lines related to that\n
# order/invoice, we give high priority to those supply lines\n
for trade_condition in getRelatedTradeConditionList(explanation):\n
high_priority_supply_line_list.extend(\n
list(trade_condition.contentValues(\n
portal_type=context.getPortalSupplyPathTypeList(),\n
checked_permission=\'View\')))\n
\n
# XXX FIXME: Hardcoded values\n # XXX FIXME: Hardcoded values\n
if "Purchase" in explanation_type:\n if "Purchase" in explanation_type:\n
kw[\'sort_method\'] = resourcePurchasePriceSortMethod\n kw[\'sort_method\'] = getResourcePurchasePriceSortMethod(\n
high_priority_supply_line_list)\n
elif "Sale" in explanation_type:\n elif "Sale" in explanation_type:\n
kw[\'sort_method\'] = resourceSalePriceSortMethod\n kw[\'sort_method\'] = getResourceSalePriceSortMethod(\n
high_priority_supply_line_list)\n
\n \n
resource = context.getResourceValue()\n resource = context.getResourceValue()\n
if resource is not None:\n if resource is not None:\n
return resource.getPriceCalculationOperandDict(\n r = resource.getPriceCalculationOperandDict(\n
default=default, context=context, **kw)\n default=default, context=context, **kw)\n
return r\n
\n
return default\n return default\n
</string> </value> </string> </value>
</item> </item>
...@@ -168,19 +214,25 @@ return default\n ...@@ -168,19 +214,25 @@ return default\n
<tuple> <tuple>
<string>default</string> <string>default</string>
<string>kw</string> <string>kw</string>
<string>sourceSortMethod</string> <string>sourceSectionSortMethod</string>
<string>destinationSortMethod</string> <string>destinationSectionSortMethod</string>
<string>resourcePurchasePriceSortMethod</string> <string>getResourcePurchasePriceSortMethod</string>
<string>resourceSalePriceSortMethod</string> <string>getResourceSalePriceSortMethod</string>
<string>getRelatedTradeConditionList</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>explanation</string> <string>explanation</string>
<string>AttributeError</string> <string>AttributeError</string>
<string>None</string> <string>None</string>
<string>explanation_type</string> <string>explanation_type</string>
<string>high_priority_supply_line_list</string>
<string>_getiter_</string>
<string>trade_condition</string>
<string>list</string>
<string>_write_</string> <string>_write_</string>
<string>resource</string> <string>resource</string>
<string>_apply_</string> <string>_apply_</string>
<string>r</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -201,6 +253,10 @@ return default\n ...@@ -201,6 +253,10 @@ return default\n
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Movement_getPriceCalculationOperandDict</string> </value> <value> <string>Movement_getPriceCalculationOperandDict</string> </value>
</item> </item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>uid</string> </key> <key> <string>uid</string> </key>
<value> <value>
......
2008-08-06 jerome
* Change Movement_getPriceCalculationOperandDict to use source_section / destination_section instead of source / destination.
* Change Movement_getPriceCalculationOperandDict to give priority to supply lines contained in related trade conditions.
2008-08-05 vincentd 2008-08-05 vincentd
* Add two new parameter for jumping with the method Base_jumpToRelatedObject, one for * Add two new parameter for jumping with the method Base_jumpToRelatedObject, one for
chose to take another item as context and another for choosing a different form_id if there is only one object for jump chose to take another item as context and another for choosing a different form_id if there is only one object for jump
......
928 929
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment