Discussion:
[Erp5-dev] PackingList_doSolveActions - bug fixed
Shresth K
2007-05-15 06:37:32 UTC
Permalink
Encountered a bug while choosing individual solvers for each Purchase
Packing List Line. Looked for it in erp-report archives and did not find any
fix for it. The dictionary access was erroneous. Herein is the correction.
Don't know how to get the .xml diff hence submitting it this way.





















## Script (Python) "PackingList_doSolveActions"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=form_id, dialog_id='', **kw
##title=
##
request = context.REQUEST

listbox = request.get('listbox')
start_date = context.getStartDate()
stop_date = context.getStopDate()
tag = context.getPath() + '_split'

split_and_defer = 0

if listbox is not None:
context.updateAppliedRule("default_delivery_rule")

-
+
+

for line in listbox:
for line_key in listbox:
line = listbox[line_key]

































url = line['listbox_key']
quantity = line['quantity']
movement = context.restrictedTraverse(url)
movement.setProperty('quantity', quantity, type='float')
choice = line['choice']
if choice == 'SplitAndDefer':
split_and_defer = 1
context.portal_simulation.solveMovement(movement, None,
"SplitAndDefer", start_date=start_date, stop_date=stop_date,
activate_kw={'tag':tag})
elif choice == 'CopyToTarget':
context.portal_simulation.solveMovement(movement,
None,"CopyToTarget")

context.updateCausalityState()

if split_and_defer:
# Create delivery
order = context.getCausalityValue()
applied_rule =
order.getCausalityRelatedValue(portal_type="Applied Rule")

order_portal_type = order.getPortalType()
if order_portal_type == 'Sale Order':
delivery_builder = order.portal_deliveries.sale_packing_list_builder
elif order_portal_type == 'Purchase Order':
delivery_builder =
order.portal_deliveries.purchase_packing_list_builder

explanation_uid_list = [order.getUid(),context.getUid()]
delivery_builder.activate(activity='SQLQueue',after_tag=tag).build(explanation_uid=explanation_uid_list)


redirect_url = '%s/%s?%s' % (context.absolute_url(), form_id,

'portal_status_message=Sale+Packing+List+updated.')
context.REQUEST[ 'RESPONSE' ].redirect( redirect_url )


Regards,
Shresth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20070515/7883461d/attachment.htm>
Alexandre Boeglin
2008-01-30 15:03:41 UTC
Permalink
Post by Shresth K
Encountered a bug while choosing individual solvers for each Purchase
Packing List Line. Looked for it in erp-report archives and did not
find any fix for it. The dictionary access was erroneous. Herein is
the correction.
Don't know how to get the .xml diff hence submitting it this way.
Hello,

Thank you for you patch, and sorry for the delay ... It seems we
overlooked this one.

Alex

Loading...