[Erp5-dev] PackingList_doSolveActions - bug fixed

Shresth K shresth.k at gmail.com
Tue May 15 08:37:32 CEST 2007


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>


More information about the Erp5-dev mailing list