Commit d9a2d1c8 authored by Jean-Paul Smets's avatar Jean-Paul Smets

initial checkin


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1221 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8675dc7d
## Script (Python) "Organisation_getOneLineAddress"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
address = context.getDefaultAddress()
if address != None:
zip_code = context.getDefaultAddress().getZipCode()
city = context.getDefaultAddress().getCity()
else:
zip_code = ''
city = ''
region = context.getDefaultAddressRegion()
if region == None:
region = ''
else:
region = region.split('/')[-1]
return 'Lieu livraison : %s %s %s' % (zip_code, city, region)
## Script (Python) "Coramy_sendMailToUser"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=user_name='rc',mMsg='Message par dfaut', mSubj='Sujet par dfaut',**kw
##title=
##
try:
mailhost=getattr(context, context.portal_url.superValues('Mail Host')[0].id)
except:
raise AttributeError, "Cannot find a Mail Host object"
mFrom = context.portal_properties.email_from_name+' <'+context.portal_properties.email_from_address+'>'
# Only for doing test
if user_name == 'rc':
user_name = 'Romain_Courteaud'
mTo = user_name + '@coramy.com'
try:
# send mail to user
mailhost.send(mMsg,mTo,mFrom,mSubj)
# send mail to admin
mailhost.send(mMsg,mFrom,mFrom,mSubj)
except:
mNewMsg = 'Sujet ' + mSubj + '\n'
mNewMsg += 'Destinataire ' + mTo + '\n'
mNewMsg += 'Message ' + mMsg + '\n'
mailhost.send(mNewMsg,mFrom,mFrom,"ERP5:Coramy_sendMailToUser:Erreur")
## Script (Python) "Coramy_userLabelPrinterDefinition"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=user_name=None
##title=
##
if user_name==None:
local_user = context.portal_membership.getAuthenticatedMember().getUserName()
else:
local_user = user_name
printer_dict = {
'Nicole_Denis' : 'Meto_XS40_2',
'Christelle_Megret' : 'Meto_XS40_3',
'Jocelyne_Olejarz' : 'Meto_XS40_4',
'Nathalie_Wadoux' : 'Meto_XS40_5',
'Chantal_Hannequin' : 'Meto_XS40_5',
'Joelle_Gorriez': 'Meto_XS40_6',
'Gaelle_Manier' : 'Meto_XS40_6'
}
if local_user in printer_dict.keys():
printer_name = printer_dict[local_user]
else:
printer_name = 'Meto_XS40_2'
return printer_name
## Script (Python) "Coramy_userPrinterDefinition"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=user_name=None
##title=
##
if user_name==None:
local_user = context.portal_membership.getAuthenticatedMember().getUserName()
else:
local_user = user_name
printer_dict = {
}
if local_user in printer_dict.keys():
printer_name = printer_dict[local_user]
else:
printer_name = 'Xerox_DC_440'
return printer_name
## Script (Python) "Inventory_checkConsistency"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
olist = list(context.inventaire_mp.objectValues()) + list(context.inventaire_pf.objectValues())
for o in olist:
for l in o.objectValues(spec=('CORAMY Inventory Line','ERP5 Inventory Line')):
if l.hasCellContent():
for c in l.objectValues(spec=('CORAMY Inventory Cell','ERP5 Inventory Cell')):
inventory = getattr(c, 'inventory', 0.0) # We have no acquisition here (None at class level ?)
line_inventory = getattr(l, 'inventory', 0.0)
if line_inventory is None: line_inventory = 0.0
if inventory == 0.0 and line_inventory != 0.0 and len(l.objectValues(spec=('CORAMY Inventory Cell','ERP5 Inventory Cell'))) == 1:
print "Fixing Error on %s" % c.getRelativeUrl()
c.edit(inventory = line_inventory, force_update =1 )
return printed
## Script (Python) "Inventory_copyDefault"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
for l in context.objectValues(spec=('CORAMY Inventory Line','ERP5 Inventory Line')):
if l.hasCellContent():
for c in l.objectValues(spec=('CORAMY Inventory Cell','ERP5 Inventory Cell')):
inventory = getattr(c, 'inventory', 0.0) # We have acquisition here
if inventory is None: inventory=0.0
print "Update Cell %s %s" % (getattr(c, 'inventory', 0.0), inventory)
if inventory == 0.0: c.edit(inventory = inventory, force_update=1) # Only update if 0.0
else:
inventory = getattr(l, 'inventory', 0.0)
if inventory is None: inventory=0.0
print "Update Line %s %s" % (getattr(l, 'inventory', 0.0), inventory)
if inventory == 0.0: l.edit(inventory = inventory, force_update=1) # Only update if 0.0
return printed
## Script (Python) "Inventory_updateDefault"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
for o in context.inventaire_mp.objectValues():
print "Inventory copy default %s" % o.getRelativeUrl()
o.activate(priority=3).Inventory_copyDefault()
for o in context.inventaire_pf.objectValues():
print "Inventory copy default %s" % o.getRelativeUrl()
o.activate(priority=3).Inventory_copyDefault()
return printed
## Script (Python) "Item_doWorkflowTransition"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=workflow_action='', workflow_id=''
##title=
##
# A shorter version of of workflow_status_modify and folder_workflow_status_modify ...
error_message = ''
action_list = context.portal_workflow.getActionsFor(context)
action_list = filter(lambda x:x.has_key('id'), action_list )
action_id_list = map(lambda x:x['id'], action_list)
# If the user is not allowed to do this transition, it will not be in action_list
if workflow_action in action_id_list:
context.portal_workflow.doActionFor(
context,
workflow_action,
wf_id=workflow_id
)
# We will check if there's an error_message
history_data = None
try:
history_data = context.portal_workflow.getInfoFor(ob=context, name='history')
except:
pass
redirect_url = None
if history_data is not None:
last_history_data = history_data[len(history_data)-1]
this_error = last_history_data.get('error_message')
if this_error != None and this_error != '':
error_message += this_error + "-"
return error_message
## Script (Python) "Item_resetLocation"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
item = context
item.setLocation('')
## Script (Python) "PackingList_cleanupAssortiment"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
# This script cleans packing lists we deffective quantities equal to 0.0 by resetting quantities
# to values in the simulation
for movement_brain in context.PackingList_searchAssortiment():
movement = movement_brain.getObject()
if movement.getQuantity() == 0.0:
if movement.getRelatedQuantity() is not None:
print "Fix movement %s from %s to %s" % (movement.getRelativeUrl(), movement.getQuantity(), movement.getRelatedQuantity())
#movement.setQuantity(movement.getRelatedQuantity())
else:
print "### Error movement %s has no simulation" % movement.getRelativeUrl()
else:
print "### NONSENSE on %s" % movement.getRelativeUrl()
return printed
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT DISTINCT
movement_c.*
FROM
catalog, catalog AS resource, movement, catalog AS movement_c
WHERE
movement.delivery_uid = catalog.uid
AND catalog.portal_type = "Sales Packing List"
AND resource.uid = movement.resource_uid
AND resource.portal_type = "Assortiment"
AND (movement.quantity is NULL OR movement.quantity = 0.0)
AND (movement.target_quantity is NULL OR movement.target_quantity = 0.0)
AND movement_c.uid = movement.uid
AND movement_c.portal_type = "Sales Packing List Line"
\ No newline at end of file
## Script (Python) "PackingList_setTargetStopToTargetStart"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
packing_list = context
packing_list.setTargetStopDate(packing_list.getTargetStartDate())
## Script (Python) "PdfTemplate_changePdfStylesheet"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=stylesheet_name='default_pdf_template_save'
##title=
##
context.setProperty('pdf_Stylesheet',stylesheet_name)
## Script (Python) "PieceTissu_deleteFromMovement"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
piece_dict = {}
piece_dict['41874']='livraison_fabrication/2004/7/movement_0_0'
piece_dict['40398']='livraison_fabrication/1838/4/movement_5_0'
piece_dict['41975']='livraison_fabrication/1873/11/movement_0_0'
piece_dict['42254']='mouvement_mp/102/19/movement_0_0'
piece_dict['36473']='livraison_fabrication/1967/1/movement_0_0'
piece_dict['36555']='mouvement_mp/98/9/movement_0_0'
piece_dict['40226']='mouvement_mp/102/9/movement_0_0'
piece_dict['40145']='livraison_fabrication/2028/8/movement_3_0'
piece_dict['40092']='livraison_fabrication/1946/1/movement_0_0'
piece_dict['41789']='mouvement_mp/82/1/movement_0_0'
piece_dict['41586']='livraison_fabrication/1950/2/movement_2_0'
for key in piece_dict.keys() :
mouvement = context.restrictedTraverse(piece_dict[key])
if mouvement is not None :
if piece_dict[key].find('mouvement_mp') != -1 :
if mouvement.getProductionQuantity() > 0 :
item_id_list = mouvement.getProducedItemIdList()
new_item_id_list = filter(lambda k_item: k_item != key, item_id_list)
mouvement.setProducedItemIdList(new_item_id_list)
else :
item_id_list = mouvement.getConsumedItemIdList()
new_item_id_list = filter(lambda k_item: k_item != key, item_id_list)
mouvement.setConsumedItemIdList(new_item_id_list)
else :
item_id_list = mouvement.getItemIdList()
new_item_id_list = filter(lambda k_item: k_item != key, item_id_list)
mouvement.setItemIdList(new_item_id_list)
print piece_dict[key], item_id_list, new_item_id_list, key
return printed
## Script (Python) "PieceTissu_exportList"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
piece_list = context.zGetLocatedPieceTissuList()
cr = '\r'
tab = '\t'
movement_log = 'Piece'+tab+tab+'Quantit initiale'+tab+'Quantit restante'+cr
for piece_item in piece_list :
piece= piece_item.getObject()
movement_log += piece.getRelativeUrl()+tab+piece.getId()+tab+str(piece.getQuantity())+tab+str(piece.getRemainingQuantity())+tab+piece.getLocation()+tab+piece.getComment().replace('\r',' ') + cr
request.RESPONSE.setHeader('Content-Type','application/text')
return movement_log
## Script (Python) "PieceTissu_findNegativeQty"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
cr = '\n'
tab = '\t'
movement_log = 'Problmes'+cr
piece_list = context.portal_catalog(portal_type=('Piece Tissu',))
for piece_item in piece_list :
piece = piece_item.getObject()
if piece is not None :
qty = piece.getRemainingQuantity()
if qty < 0 :
movement_log += piece.getRelativeUrl()+tab+str(qty)+cr
request.RESPONSE.setHeader('Content-Type','application/text')
return movement_log
## Script (Python) "PieceTissu_findSuspectMovement"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
cr = '\n'
tab = '\t'
movement_log = 'Id pieces'+tab+'piece_relative_url'+tab+'In-Out'+tab+'number'+tab+'relative_url_movement'+cr
piece_list = context.portal_catalog(portal_type=('Piece Tissu',))
#piece_list = context.portal_catalog(id = ('41890','36921') , portal_type="Piece Tissu")
for piece_item in piece_list :
out_movement_list = ''
out_count = 0
in_movement_list = ''
in_count = 0
suspect_movement_list = ''
suspect_count = 0
piece = piece_item.getObject()
if piece is not None :
related_movement_list = piece.getAggregateRelatedValueList()
for movement in related_movement_list :
movement_relative_url = movement.getRelativeUrl()
if movement_relative_url.find('livraison_fabrication') != -1 :
out_movement_list += movement_relative_url + tab
out_count += 1
elif movement_relative_url.find('inventaire_mp') != -1 :
in_movement_list += movement_relative_url + tab
in_count += 1
elif movement_relative_url.find('livraison_achat') != -1 :
in_movement_list += movement_relative_url + tab
in_count += 1
elif movement_relative_url.find('mouvement_mp') != -1 :
if movement.getProductionQuantity() > 0 :
in_movement_list += movement_relative_url + tab
in_count += 1
elif movement.getConsumptionQuantity() > 0 :
out_movement_list += movement_relative_url + tab
out_count += 1
else :
suspect_movement_list += movement_relative_url + tab
suspect_count += 1
else :
suspect_movement_list += movement_relative_url + tab
suspect_count += 1
if (in_count==1 and out_count==1 and suspect_count==0) or (in_count==1 and out_count==0 and suspect_count==0) or (in_count==0 and out_count==0 and suspect_count==0):
pass
elif (in_count==0 and out_count==1 and suspect_count==0) :
if piece.aq_parent.getPortalType()=="Piece Tissu" :
pass
else :
movement_log += piece.getId() + tab + piece.getRelativeUrl() + tab + 'OUT' + tab + str(out_count) + tab + out_movement_list + cr
else :
if in_count > 0 :
movement_log += piece.getId() + tab + piece.getRelativeUrl() + tab + 'IN' + tab + str(in_count) + tab + in_movement_list + cr
if out_count > 0 :
movement_log += piece.getId() + tab + piece.getRelativeUrl() + tab + 'OUT' + tab + str(out_count) + tab + out_movement_list + cr
if suspect_count > 0 :
movement_log += piece.getId() + tab + piece.getRelativeUrl() + tab + 'SUSPECT' + tab + str(suspect_count) + tab + suspect_movement_list + cr
request.RESPONSE.setHeader('Content-Type','application/text')
return movement_log
## Script (Python) "SalesOrder_updateAssortimentPrice"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
assort_dict ={}
assort_dict['009H401_12P_H']=51.00
assort_dict['009H402_12P_H']=47.40
assort_dict['009H403_12P_H']=57.00
assort_dict['108E5386_12P_H']=150.00
assort_dict['108H401_12P_H']=145.80
assort_dict['11414442_12P_H']=182.40
assort_dict['11495210_12P_H']=171.60
assort_dict['114H401_12P_H']=264.00
assort_dict['114H402_12P_H']=240.00
assort_dict['114H403_12P_H']=214.80
assort_dict['11684401_12P_H']=136.80
assort_dict['116H401_12P_H']=147.00
assort_dict['116H402_12P_H']=144.00
assort_dict['118H401_12P_H']=151.20
assort_dict['118H402_12P_H']=117.60
assort_dict['124H401_12P_H']=135.60
assort_dict['134A0104_12P_H']=115.20
assort_dict['136H401_12P_H']=149.40
assort_dict['136H402_12P_H']=192.00
assort_dict['136H403_12P_H']=192.00
assort_dict['137H401_18P_H']=234.00
assort_dict['140H401_12P_H']=107.16
assort_dict['140H402_12P_H']=109.59
assort_dict['141H401_12P_H']=131.64
assort_dict['14693101_12P_H']=199.20
assort_dict['153E5245_12P_H']=166.80
assort_dict['153F5340_12P_H']=166.80
assort_dict['153H402_12P_H']=186.00
assort_dict['153H403_12P_H']=183.00
assort_dict['15554770_12P_H']=144.00
assort_dict['15873440_12P_H']=172.80
assort_dict['158H401_12P_H']=138.00
assort_dict['16863440_12P_H']=171.60
assort_dict['168H401_12P_H']=150.00
assort_dict['168H402_12P_H']=168.00
assort_dict['168H403_12P_H']=138.00
assort_dict['169H401_12P_H']=107.16
assort_dict['169H402_12P_H']=152.40
assort_dict['169H403_12P_H']=163.20
assort_dict['19015387_18P_H']=216.00
assort_dict['19015896_12P_H']=144.00
assort_dict['213H401_12P_H']=148.20
assort_dict['223H401_12P_H']=139.20
assort_dict['223H402_12P_H']=139.20
assort_dict['230H401_12P_H']=159.60
assort_dict['232H401_12P_H']=142.80
assort_dict['232H402_12P_H']=140.40
assort_dict['232H403_12P_H']=156.00
assort_dict['233H402_12P_H']=126.00
assort_dict['233H403_12P_H']=216.00
assort_dict['236H401_12P_H']=174.00
assort_dict['237H401_12P_H']=150.00
assort_dict['237H402_12P_H']=138.00
assort_dict['237H403_12P_H']=118.80
assort_dict['237H404_12P_H']=171.00
assort_dict['237H405_12P_H']=135.00
assort_dict['237H406_12P_H']=115.20
assort_dict['237H407_12P_H']=174.00
assort_dict['237H412_12P_H']=150.00
assort_dict['240H401_12P_H']=146.40
assort_dict['240H402_12P_H']=151.20
assort_dict['240H403_12P_H']=139.20
assort_dict['245H401_12P_H']=216.00
assort_dict['246H401_12P_H']=187.20
assort_dict['247H401_12P_H']=234.00
assort_dict['247H402_12P_H']=216.00
assort_dict['24800156_12P_H']=82.80
assort_dict['24805576_12P_H']=83.40
assort_dict['24850104_12P_H']=94.80
assort_dict['24850134_12P_H']=90.00
assort_dict['24860157_12P_H']=87.60
assort_dict['248B5000_12P_H']=91.20
assort_dict['248H402_12P_H']=216.00
assort_dict['248H403_12P_H']=231.60
assort_dict['248H404_12_H']=201.60
assort_dict['248H405_12P_H']=216.00
assort_dict['248H406_12P_H']=211.20
assort_dict['248H407_12P_H']=188.40
assort_dict['248H408_12P_H']=190.80
assort_dict['248H409_12P_H']=183.00
assort_dict['248H410_12P_H']=196.80
assort_dict['25040169_12P_H']=81.00
assort_dict['25042733_12P_H']=88.80
assort_dict['25065455_12P_H']=114.00
assort_dict['251H401_12P_H']=180.00
assort_dict['251H402_12P_H']=189.60
assort_dict['251H403_12P_H']=148.80
assort_dict['251H405_12P_H']=213.60
assort_dict['25365673_12P_H']=98.40
assort_dict['25415284_12P_H']=102.00
assort_dict['25415674_12P_H']=99.60
assort_dict['26220104_12P_H']=126.00
assort_dict['27165093_12P_H']=160.80
assort_dict['27284967_12P_H']=159.00
assort_dict['274E5600_12P_H']=152.40
assort_dict['335H401_12P_H']=174.00
assort_dict['335H402_12P_H']=174.00
assort_dict['352H401_12P_H']=60.60
assort_dict['354H401_12P_H']=97.32
assort_dict['372H401_12P_H']=123.60
assort_dict['401H401_12P_H']=74.40
assort_dict['401H402_12P_H']=127.20
assort_dict['405H401_12P_H']=116.40
assort_dict['406H402_18P_H']=115.20
assort_dict['406H403_12P_H']=88.80
assort_dict['40700157_12P_H']=72.00
assort_dict['40750109_12P_H']=67.20
assort_dict['408H401_12P_H']=102.00
assort_dict['41335586_12P_H']=68.40
assort_dict['415H401_18P_H']=104.40
assort_dict['415H402_12P_H']=90.00
assort_dict['415H404_12P_H']=99.60
assort_dict['416H401_12P_H']=87.60
assort_dict['416H402_12P_H']=91.20
assort_dict['416H403_12P_H']=80.40
assort_dict['416H404_12P_H']=114.00
assort_dict['420H401_12P_H']=96.00
assort_dict['42225455_12P_H']=84.00
assort_dict['42232733_12P_H']=70.80
assort_dict['423H401_12P_H']=94.80
assort_dict['423H402_18P_H']=147.60
assort_dict['423H403_18P_H']=178.20
assort_dict['423H404_12P_H']=93.60
assort_dict['42420163_12P_H']=59.40
assort_dict['42435683_12P_H']=64.80
assort_dict['500H401_12P_H']=79.20
assort_dict['511H401_12P_H']=100.20
assort_dict['511H402_12P_H']=99.00
assort_dict['518E0157_12P_H']=67.20
assort_dict['518H401_12P_H']=76.80
assort_dict['519H401_12P_H']=90.00
assort_dict['52020109_12P_H']=75.60
assort_dict['52185530_12P_H']=71.40
assort_dict['527H401_12P_H']=103.20
assort_dict['527H402_12P_H']=68.40
assort_dict['52830164_12P_H']=54.00
assort_dict['52835683_12P_H']=68.40
assort_dict['528H401_12P_H']=90.00
assort_dict['53580108_12P_H']=51.60
assort_dict['536H401_12P_H']=74.76
assort_dict['536H402_12P_H']=85.68
assort_dict['536H403_12P_H']=67.32
assort_dict['537H401_12P_H']=74.76
assort_dict['537K0107_12P_H']=44.40
assort_dict['537K4747_12P_H']=58.80
assort_dict['538H401_12P_H']=83.40
assort_dict['538H402_12P_H']=114.00
assort_dict['543H401_12P_H']=82.80
assort_dict['590A5151_12P_H']=42.00
assort_dict['593K4747_12P_H(2-8)']=36.00
assort_dict['593K4747_12P_H(6-24m)']=33.60
assort_dict['593M5000_12P_H']=38.40
assort_dict['636H401_12P_H']=70.80
assort_dict['656H401_12P_H']=52.08
assort_dict['658H401_12P_H']=72.84
assort_dict['701H401_12P_H']=47.40
assort_dict['701H402_12P_H']=43.20
assort_dict['701H403_12P_H']=59.40
assort_dict['70255000_12P_H(10-16)']=43.80
assort_dict['70255000_16P_H(2-8)']=52.80
assort_dict['702H401_12P_H']=45.00
assort_dict['709H401_12P_H']=54.00
assort_dict['712H401_12P_H']=51.60
assort_dict['712H402_12P_H']=49.80
assort_dict['712H403_12P_H']=57.00
assort_dict['712H404_18P_H']=85.50
assort_dict['712K0108_12P_H']=39.00
assort_dict['712K0150_12P_H']=42.00
assort_dict['713H401_12P_H']=56.40
assort_dict['71414760_12P_H']=44.40
assort_dict['71415665_16P_H']=44.00
assort_dict['714B5306_12P_H']=43.80
assort_dict['714H401_12P_H']=42.00
assort_dict['714H402_12P_H']=51.48
assort_dict['714H403_12P_H']=42.24
assort_dict['714H404_12P_H']=51.60
assort_dict['715H401_12P_H']=57.60
assort_dict['715H402_12P_H']=51.60
assort_dict['720A5265_12P_H']=40.20
assort_dict['720H401_12P_H']=52.20
assort_dict['720H402_12P_H']=64.80
assort_dict['72374749_12P_H']=52.80
assort_dict['72375665_16P_H']=56.00
assort_dict['723H401_18P_H']=83.70
assort_dict['723H402_12P_H']=70.80
assort_dict['724H401_12P_H']=79.56
assort_dict['724h402_18P_H']=90.00
assort_dict['725H401_12P_H']=70.80
assort_dict['725J0108_12P_H']=43.20
assort_dict['725J0150_12P_H']=43.80
assort_dict['727H401_12P_H']=60.00
assort_dict['72845000_12P_H(10-16)']=54.00
assort_dict['72845000_16P_H(2-8)']=63.20
assort_dict['75105143_12P_H']=61.20
assort_dict['751H401_12P_H']=75.60
assort_dict['751H402_12P_H']=63.00
assort_dict['755H401_16P_H']=76.00
assort_dict['769H401_12P_H']=70.44
assort_dict['769H402_16P_H']=91.20
assort_dict['77045143_12P_H']=47.40
assort_dict['770H401_12P_H']=67.32
assort_dict['770H402_12P_H']=64.92
assort_dict['770H403_12P_H']=79.20
assort_dict['770H404_16P_H']=116.00
assort_dict['770H405_12P_H']=63.00
assort_dict['77115217_12P_H']=62.40
assort_dict['77115401_12P_H']=70.80
assort_dict['771H401_12P_H']=66.72
assort_dict['771H402_12P_H']=97.80
assort_dict['771H403_16P_H']=84.00
assort_dict['771H404_12P_H']=66.00
assort_dict['772H401_12P_H']=68.40
assort_dict['774H402_16P_H']=108.00
assort_dict['774H403_16P_H']=130.40
assort_dict['775H401_12P_H']=88.80
assort_dict['775H402_16P_H']=159.20
assort_dict['776H401_16P_H']=110.40
assort_dict['778H401_16P_H']=120.00
assort_dict['778H402_12P_H']=85.80
assort_dict['855H401_12P_H']=39.00
assort_dict['869H401_12P_H']=53.40
assort_dict['910H401_12P_H']=149.40
order = context
assort_keys = assort_dict.keys()
movement_list = order.getMovementList()
for movement in movement_list :
resource = movement.getResourceValue()
if resource is not None :
if resource.getPortalType() == "Assortiment" :
assort_id = resource.getId()
if assort_id in assort_keys :
movement.setProperty(key='price',value=assort_dict[assort_id])
#print "prix actuel : "+str(movement.getPrice())+" prix assortiment : "+str(assort_dict[assort_id])
#return printed
<dtml-comment>
title:
connection_id:MySQL
max_rows:100000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT group_client.title, sum(movement.quantity) AS qte1, sum(movement.total_price) AS total_prix1,sum(other_movement.quantity) AS qte2, sum(other_movement.total_price) AS total_prix2
FROM catalog AS sale_order, catalog AS order_line, category AS category_sc
LEFT JOIN catalog as order_cell ON (order_cell.parent_uid = order_line.uid AND order_cell.portal_type = "Delivery Cell")
LEFT JOIN movement ON ( movement.uid = order_cell.uid
AND movement.has_cell_content = 0 )
LEFT JOIN movement AS other_movement ON ( other_movement.uid = order_line.uid
AND other_movement.has_cell_content = 0 )
LEFT JOIN category AS category_group ON ( category_group.uid=sale_order.uid
AND category_group.base_category_uid = <dtml-var "portal_categories.group.uid">
AND category_group.category_strict_membership = 1 )
LEFT JOIN catalog AS group_client ON ( group_client.uid = category_group.category_uid )
WHERE sale_order.portal_type = "Sales Order"
AND order_line.parent_uid = sale_order.uid
AND order_line.portal_type = "Sales Order Line"
AND (sale_order.simulation_state = "planned"
OR sale_order.simulation_state = "ordered"
OR sale_order.simulation_state = "draft"
OR sale_order.simulation_state = "confirmed")
AND category_sc.uid=sale_order.uid
AND category_sc.base_category_uid = <dtml-var "portal_categories.source_section.uid">
AND category_sc.category_uid = <dtml-var "portal_categories.group.Coramy.Houvenaegel.uid">
GROUP BY group_client.title
\ No newline at end of file
## Script (Python) "changeSourceAdministrationList"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
order_list = context.changeSourceAdministrationSQL()
i = 1
for order in order_list:
order_object = order.getObject()
source_admin = order_object.getSourceAdministration()
if source_admin != 'person/347':
print order_object.getId(), order_object.getComment()
i += 1
print 'fin'
return printed
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT DISTINCT id, relative_url, path, Description
FROM catalog
WHERE simulation_state = "draft"
AND portal_type = "Sales Order"
\ No newline at end of file
## Script (Python) "check_production_delivery"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
delivery_list = context.object_action_list(selection_name='production_packing_list_selection')
for delivery in delivery_list :
print '\n'+'Livraison :'+delivery.getId()
movement_list = delivery.getMovementList()
for movement in movement_list :
item_list = movement.getAggregateValueList()
if not item_list in ([], None) :
quantity = 0
for item in item_list :
# print movement.getResource(),movement.getVariationCategoryList(),item.getResource(),item.getVariationCategoryList()
# verify if resource of item == resource of movement
if movement.getResource() == item.getResource() :
# check if variation_category is the same
if movement.getVariationCategoryList() != item.getVariationCategoryList() :
print 'Problme de variante',movement.getVariationCategoryList(),item.getId(),item.getVariationCategoryList()
else :
print 'Problme de resource',movement.getResource(),item.getId(),item.getResource()
# print movement.getResource(), movement.getItemIdList()
# verify if quantity of movement == sum (item.getRemainingQuantity)
quantity += item.getRemainingQuantity()
if quantity != movement.getTargetQuantity() :
print 'Problme de quantit',movement.getTargetQuantity(),round(quantity,4)
return printed
## Script (Python) "getOneLineShortDescription"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=description='',len_max=100
##title=
##
# cut the description to fit under len_max caracteres
from string import join
result = description.split('\n')[0]
if len(result) > len_max:
result = join(result[:len_max].split(' ')[:-2]) + '...'
else:
result = description
return result
## Script (Python) "launchChangeEipAndCollection"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
item_list = context.zGetEipChangeObjectlist()
cr = '\n'
tab = '\t'
for item_item in item_list :
item = item_item.getObject()
if item is not None:
item.activate(priority=2).updateEipAndCollection()
#request.RESPONSE.setHeader('Content-Type','application/text')
return 'lanc'+str(len(item_list))
## Script (Python) "launchResetLocationOnLocatedPieceTissu"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
item_list = context.zGetLocatedPieceTissuList()
cr = '\n'
tab = '\t'
for item_item in item_list :
item = item_item.getObject()
if item is not None:
context.portal_activities.newMessage('SQLDict', item.getPath(), None, {}, 'Item_resetLocation')
#request.RESPONSE.setHeader('Content-Type','application/text')
return 'fait'
## Script (Python) "launchResetTargetQtyOnItemAggregatedMovement"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
movement_list = context.zGetTissuMovementWithoutItem()
cr = '\n'
tab = '\t'
movement_log = 'Problme'+cr
for movement_item in movement_list :
movement = movement_item.getObject()
if movement is not None:
context.portal_activities.newMessage('SQLDict', movement.getPath(), None, {}, 'Movement_resetTargetQuantity')
# movement_log.append(movement.getRelativeUrl())
#request.RESPONSE.setHeader('Content-Type','application/text')
return 'fait'
## Script (Python) "launchSetStopDateONProdDelivery"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
packing_list = context.zGetProductionDeliveryList()
cr = '\n'
tab = '\t'
for packing_item in packing_list :
packing = packing_item.getObject()
if packing is not None:
packing.activate().recursiveImmediateReindexObject()
return 'lanc'
## Script (Python) "launchTransferVetement"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
item_list = context.zGetVetementList()
cr = '\n'
tab = '\t'
for item_item in item_list :
item = item_item.getObject()
if item is not None:
item.activate().transfer_vetement()
#request.RESPONSE.setHeader('Content-Type','application/text')
return 'lanc'+str(len(item_list))
## Script (Python) "launchUpdateAssortimentPriceOnSalesOrder"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
item_list = context.zGetHouvSalesOrderList()
cr = '\n'
tab = '\t'
for item_item in item_list :
item = item_item.getObject()
if item is not None:
item.activate().SalesOrder_updateAssortimentPrice()
#request.RESPONSE.setHeader('Content-Type','application/text')
return 'lanc'+str(len(item_list))
## Script (Python) "launchUpdateQuantityOnItemAggregatedMovement"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
movement_list = context.zGetItemAggregatedMovement()
cr = '\n'
tab = '\t'
movement_log = 'Problme'+cr
for movement_item in movement_list :
movement = movement_item.getObject()
if movement is not None:
context.portal_activities.newMessage('SQLDict', movement.getPath(), None, {}, 'updateQuantityOnItemAggregatedMovement')
# movement_log.append(movement.getRelativeUrl())
request.RESPONSE.setHeader('Content-Type','application/text')
return 'fait'
<?xml version="1.0" encoding="iso-8859-1"?>
<form>
<title></title>
<name>test_form</name>
<action></action>
<enctype></enctype>
<method>POST</method>
<pt>form_view</pt>
<groups>
<group>
<title>Default</title>
<fields>
<field><id>xxx</id> <type>TextAreaField</type>
<values>
<alternate_name></alternate_name>
<css_class></css_class>
<default></default>
<description></description>
<external_validator></external_validator>
<extra></extra>
<height type="int">5</height>
<hidden type="int">0</hidden>
<max_length></max_length>
<max_linelength></max_linelength>
<max_lines></max_lines>
<required type="int">1</required>
<title>xxx</title>
<width type="int">40</width>
</values>
<tales>
<default>request/toto</default>
<description>request/toto</description>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
<message name="required_not_found">Input is required but no input given.</message>
<message name="too_many_lines">You entered too many lines.</message>
<message name="line_too_long">A line was too long.</message>
<message name="too_long">You entered too many characters.</message>
</messages>
</field>
</fields>
</group>
</groups>
</form>
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:
class_file:
</dtml-comment>
<params></params>
SELECT DISTINCT
item.uid, item.id, item.path,
item.Description, item.simulation_state, item.default_destination_title,
stock.uid as stock_uid,
stock.node_uid as stock_node_uid,
stock.quantity as stock_quantity
FROM
catalog AS item
LEFT JOIN category, stock
ON (category.category_uid=item.uid
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.getUid()">
AND stock.uid = category.uid)
WHERE item.portal_type = "Piece Tissu"
AND item.uid=1987190823
\ No newline at end of file
## Script (Python) "test_script"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
rule = context.getSpecialiseValue()
if rule is not None:
rule.expand(context, force=1)
## Script (Python) "test_script2"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
object_list = context.object_action_list(selection_name='purchase_packing_list_selection')
for object in object_list :
object.deliver()
object.invoice()
return 'fait', len(object_list)
This diff is collapsed.
## Script (Python) "testrc"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
context.setSourceAdministration('person/347')
return 'Done'
# set the source administration
local_user = context.portal_membership.getAuthenticatedMember()
local_user_name = string.replace(local_user.getUserName(), '_', ' ')
local_persons = context.item_by_title_sql_search(title = local_user_name, portal_type = 'Person')
if len(local_persons) > 0:
print local_user.getUserName()
print local_persons[0].relative_url
else:
print 'couscous'
return printed
#
context.activate().buildDeliveryList()
return "Done"
"""
summary = context.getAggregatedAmountList()
#amount = summary[0]
#print amount['converted_quantity'], amount['efficiency']
print 'fin'
return printed
"""
"""
print float(context.getLaizeUtile())
return printed
"""
## Script (Python) "testseb"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
delivery_list =context.object_action_list(selection_name='sales_packing_list_selection',max_nb=10)
return repr(delivery_list)
## Script (Python) "testyo"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
movement_list = context.getMovementList()
movement_group = context.collectMovement(movement_list)
invoice_line_list = context.buildInvoiceLineList(movement_group)
return repr(invoice_line_list)
dict = context.showDict()
item_list = dict.items()
item_list.sort()
s = ''
for key,val in item_list:
s += "%s: %s\n" % (str(key), str(val))
return s
ret = []
invoice_line_list = context.contentValues(filter={'portal_type':'Invoice Line'})
for invoice_line in invoice_line_list:
cell_range = invoice_line.getCellRange(base_id='movement')
ret.append(cell_range)
return repr(ret)
## Script (Python) "transfer_vetement"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
vetement = context
vetement_relative_url = vetement.getRelativeUrl()
related_object_list = vetement.getSpecialiseRelatedValueList()
forme = vetement.aq_parent
vetement_module = context.getPortalObject().vetement
# copy and paste vetement
copy_data = forme.manage_copyObjects(ids=[vetement.getId()])
new_id_list = vetement_module.manage_pasteObjects(copy_data)
new_vetement = vetement_module[new_id_list[0]['new_id']]
# forme_id_list is used to build the specialise relation between the vetement and formes
forme_id_list = []
forme_id_list.append(forme.getId())
# update relation on each related_object and complete forme_id_list
for related_object in related_object_list :
category_items = related_object.getCategoryList()
filtered_items = filter(lambda cat_item:cat_item.find(vetement_relative_url) == (-1) , category_items)
# print related_object.getId()
# print len(category_items)
# print len(filtered_items)
# update categories on related_object
filtered_items.append("specialise/vetement/"+vetement.getId())
related_object.edit(categories = filtered_items)
if related_object.getPortalType() == "Modele" :
modele_forme_list = related_object.getFormeIdList()
for forme_id in modele_forme_list :
if forme_id in forme_id_list :
pass
else :
forme_id_list.append(forme_id)
#print forme_id_list
# set forme_id_list on vetement
vetement_categories = new_vetement.getCategoryList()
for forme_id in forme_id_list :
vetement_categories += ('specialise/forme/'+forme_id,)
# update fichier Lectra
fichierLectra = new_vetement.getLibrairie()+'/'+new_vetement.getId()
new_vetement.edit(categories = vetement_categories, librairie = fichierLectra)
# delete old vetement
forme.deleteContent(vetement.getId())
#return printed
## Script (Python) "updateEipAndCollection"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
# callable on tissu, modele, forme, gamme
categorie_dict = {}
categorie_dict['eip/Baby']=['eip/Baby']
categorie_dict['eip/Baby/Fille']=['eip/Baby/Fille']
categorie_dict['eip/Baby/Garcon']=['eip/Baby/Garcon']
categorie_dict['eip/Femme']=['eip/Femme']
categorie_dict['eip/Femme/Chic elegante']=['eip/Femme']
categorie_dict['eip/Femme/Classic']=['eip/Femme']
categorie_dict['eip/Femme/Confort']=['eip/Femme']
categorie_dict['eip/Femme/Cote azur']=['eip/Femme']
categorie_dict['eip/Femme/Maternite']=['eip/Femme']
categorie_dict['eip/Femme/Piscine']=['eip/Femme']
categorie_dict['eip/Femme/Rebelle attitude']=['eip/Femme']
categorie_dict['eip/Femme/Separables']=['eip/Femme']
categorie_dict['eip/Femme/Sportswear']=['eip/Femme']
categorie_dict['eip/Femme/Surf']=['eip/Femme']
categorie_dict['eip/Fille']=['eip/Fille']
categorie_dict['eip/Fille/Basic line']=['eip/Fille']
categorie_dict['eip/Fille/Junior']=['eip/Fille']
categorie_dict['eip/Fille/Nautic']=['eip/Fille']
categorie_dict['eip/Fille/Piscine']=['eip/Fille']
categorie_dict['eip/Fille/Pretty girl']=['eip/Fille']
categorie_dict['eip/Fille/Rayures']=['eip/Fille']
categorie_dict['eip/Fille/Surf']=['eip/Fille']
categorie_dict['eip/Garcon']=['eip/Garcon']
categorie_dict['eip/Garcon/Fantaisie']=['eip/Garcon']
categorie_dict['eip/Garcon/Junior']=['eip/Garcon']
categorie_dict['eip/Garcon/Piscine']=['eip/Garcon']
categorie_dict['eip/Garcon/Surf']=['eip/Garcon']
categorie_dict['eip/Homme']=['eip/Homme']
categorie_dict['eip/Homme/Basic']=['eip/Homme']
categorie_dict['eip/Homme/Classic']=['eip/Homme']
categorie_dict['eip/Homme/Piscine']=['eip/Homme']
categorie_dict['eip/Homme/Surf']=['eip/Homme']
categorie_dict['eip/Homme/Techno']=['eip/Homme']
old_category_list = context.getCategoryList()
new_category_list = []
categorie_keys = categorie_dict.keys()
for item in old_category_list :
if item in categorie_keys :
for cat_item in categorie_dict[item] :
if not cat_item in new_category_list :
new_category_list.append(cat_item)
else :
if not item in new_category_list and item.find('modele_origine') == -1:
new_category_list.append(item)
context.setCategoryList(new_category_list)
## Script (Python) "updateItemAggregatedMovement"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
movement_list = context.zGetItemAggregatedMovement()
cr = '\n'
tab = '\t'
movement_log = 'Problme'+cr
for movement_item in movement_list :
movement = movement_item.getObject()
item_list = movement.getAggregateValueList()
if not item_list in ([], None) :
quantity = 0
for item in item_list :
# verify if resource of item == resource of movement
if movement.getResource() == item.getResource() :
# check if variation_category is the same
if movement.getVariationCategoryList() != item.getVariationCategoryList() :
movement_log += movement.getRelativeUrl()+tab
movement_log += str(movement.getVariationCategoryList())+tab
movement_log += item.getRelativeUrl()+tab
movement_log += str(item.getVariationCategoryList())+tab+cr
else :
movement_log += movement.getRelativeUrl()+tab
movement_log += str(movement.getVariationCategoryList())+tab
movement_log += item.getRelativeUrl()+tab
movement_log += str(item.getVariationCategoryList())+tab+cr
# verify if quantity of movement == sum (item.getRemainingQuantity)
quantity += item.getRemainingQuantity()
if 1 : # movement_MP
if (movement.getConsumptionQuantity()+movement.getProductionQuantity()) != 0 : # :
ratio = round(quantity/(movement.getConsumptionQuantity()+movement.getProductionQuantity()),0)
else :
ratio = 0
else : # livraison_fab
if movement.getTargetQuantity() !=0 :
ratio = round(quantity/movement.getTargetQuantity(),0)
else :
ratio = 0
if ratio != 1:
movement_log += movement.getRelativeUrl()+tab
movement_log += str(movement.getVariationCategoryList())+tab
#movement_log += str(movement.getTargetQuantity())+tab
movement_log += str(movement.getConsumptionQuantity()+movement.getProductionQuantity())+tab
movement_log += str(round(quantity,4))+tab+str(ratio)+cr
request.RESPONSE.setHeader('Content-Type','application/text')
return movement_log
## Script (Python) "updateQuantityOnItemAggregatedMovement"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
movement = context
# initial_qty = movement.getTargetQuantity()
if movement.getPortalType() in ('Inventory Cell', 'Inventory Line') :
#if movement.getProductionQuantity() != 0.0 :
# movement.setProducedItemIdList(movement.getProducedItemIdList())
#elif movement.getConsumptionQuantity() != 0.0 :
# movement.setConsumedItemIdList(movement.getConsumedItemIdList())
#else : # inventory
movement.setItemIdList(movement.getItemIdList())
else : # Delivery Line or Cell
movement.setItemIdList(movement.getItemIdList())
# final_qty = movement.getTargetQuantity()
# return str(initial_qty-final_qty)
<dtml-comment>
title:
connection_id:MySQL
max_rows:100000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT DISTINCT catalog.relative_url, catalog.id, catalog.path
FROM catalog, catalog AS delivery
LEFT JOIN category ON (catalog.uid=category.category_uid
AND category.base_category_uid = <dtml-var "portal_categories.causality.uid">
AND category.uid = delivery.uid )
WHERE ( catalog.portal_type = "Sales Order"
OR catalog.portal_type = "Purchase Order"
OR catalog.portal_type = "Production Order" )
AND ( delivery.portal_type = "Sales Packing List"
OR delivery.portal_type = "Purchase Packing List"
OR delivery.portal_type = "Production Packing List" )
AND catalog.simulation_state = "confirmed"
AND category.uid IS NULL
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:100000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT catalog.id, catalog.relative_url, catalog.path, category.uid
FROM catalog
LEFT JOIN category ON ( catalog.uid=category.uid
AND category.base_category_uid = <dtml-var "portal_categories.collection.uid">
AND category.category_uid = <dtml-var "portal_categories.collection['2004'].Coramy.uid">
)
WHERE not (category.uid is NULL)
AND (catalog.portal_type = "Modele"
OR catalog.portal_type = "Forme"
OR catalog.portal_type = "Tissu"
OR catalog.portal_type = "Gamme" )
AND catalog.uid = -1893100782
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:100000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT catalog.id, catalog.relative_url, catalog.path
FROM catalog, category
WHERE catalog.uid=category.uid
AND category.base_category_uid = <dtml-var "portal_categories.source_section.uid">
AND category.category_uid = <dtml-var "portal_categories.group.Coramy.Houvenaegel.uid">
AND ( catalog.portal_type = "Sales Order"
OR catalog.portal_type = "Sales Packing List")
<dtml-comment>
title:
connection_id:MySQL
max_rows:100000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT DISTINCT catalog.relative_url, catalog.path
FROM catalog, catalog as master_item, category, stock
WHERE category.uid=stock.uid
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.uid">
AND category.category_uid = catalog.uid
AND stock.node_uid = <dtml-var "portal_categories.site.Stock_MP.Gravelines.uid">
AND stock.quantity > 0
AND catalog.parent_uid = master_item.uid
AND master_item.portal_type = "Piece Tissu"
AND catalog.portal_type = "Piece Tissu"
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:100000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT DISTINCT catalog.id, catalog.relative_url, catalog.path
FROM catalog, catalog as tissu, catalog as delivery, category, movement
WHERE catalog.uid=category.uid
AND tissu.uid = category.category_uid
AND tissu.portal_type = "Piece Tissu"
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.uid">
AND movement.uid = catalog.uid
AND delivery.uid = movement.delivery_uid
AND ( delivery.portal_type = "xProduction Packing List"
OR delivery.portal_type = "xPurchase Packing List"
OR delivery.portal_type = "Inventory MP"
OR delivery.portal_type = "xMovement MP" )
AND delivery.relative_url like "inventaire_mp/10%"
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:10000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT catalog.relative_url, catalog.path, catalog.id, resource.relative_url as resource, variation.relative_url as variation
FROM catalog
LEFT JOIN category ON (category.uid = catalog.uid
AND category.base_category_uid = <dtml-var "portal_categories.resource.uid">)
LEFT JOIN category as cat2 ON (cat2.uid = catalog.uid
AND cat2.base_category_uid = <dtml-var "portal_categories.coloris.uid">)
LEFT JOIN catalog as resource ON (resource.uid = category.category_uid)
LEFT JOIN catalog as variation ON (variation.uid = cat2.category_uid)
WHERE catalog.portal_type = "Piece Tissu"
AND catalog.location <> ''
AND catalog.location <> 'None'
AND not (category.uid is NULL OR cat2.uid is NULL)
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:100000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT DISTINCT catalog.relative_url, catalog.path
FROM catalog, catalog as resource, category
WHERE catalog.portal_type = "Piece Tissu"
AND category.uid=catalog.uid
AND category.base_category_uid = <dtml-var "portal_categories.coloris.uid">
AND category.category_uid = resource.uid
AND resource.relative_url = "tissu/TM002/blanc"
order by catalog.id
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:10000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT catalog.relative_url, catalog.path
FROM catalog
WHERE catalog.portal_type = "Production Packing List"
AND ( catalog.simulation_state = "started"
OR catalog.simulation_state = "stopped"
OR catalog.simulation_state = "delivered" )
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:10000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT
catalog.relative_url ,
movement.variation_text ,
SUM( stock.quantity ) AS inventory,
SUM( stock.total_asset_price) AS asset_price
FROM
stock
LEFT JOIN catalog ON ( catalog.uid = stock.resource_uid )
LEFT JOIN movement ON ( stock.uid = movement.uid )
WHERE
GROUP BY
stock.resource_uid , movement.variation_text
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:100000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT DISTINCT catalog.relative_url, catalog.path
FROM catalog, catalog as resource, catalog as delivery, movement
LEFT JOIN category
ON (category.uid=movement.uid
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.uid">)
WHERE movement.uid = catalog.uid
AND movement.target_quantity <> 0
AND category.uid IS NULL
AND movement.is_accountable = 1
AND resource.uid = movement.resource_uid
AND resource.portal_type = "Tissu"
AND delivery.uid = movement.delivery_uid
AND (delivery.simulation_state = "getting_ready"
OR delivery.simulation_state = "started"
OR delivery.simulation_state = "delivered")
AND ( delivery.portal_type = "Production Packing List"
OR delivery.portal_type = "Movement MP" )
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:10000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT catalog.relative_url, catalog.path
FROM catalog
WHERE catalog.portal_type = "Vetement"
AND catalog.relative_url like "forme/%"
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:
class_file:
</dtml-comment>
<params></params>
SELECT
item.id, stock.uid, stock.quantity, category.uid as cat_uid
FROM
catalog AS item
LEFT JOIN category
ON (category.category_uid=item.uid
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.getUid()">)
LEFT JOIN stock
ON (stock.uid = category.uid
AND stock.node_uid = <dtml-var "portal_categories.site.Stock_MP.Gravelines.getUid()">
AND stock.quantity < 0
)
WHERE item.portal_type = "Piece Tissu"
AND item.id = "41347"
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:
class_file:
</dtml-comment>
<params></params>
SELECT DISTINCT
count(distinct item.uid)
FROM
catalog AS item
LEFT JOIN category
ON (category.category_uid=item.uid
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.getUid()">)
LEFT JOIN movement
ON (movement.uid = category.uid)
LEFT JOIN catalog AS delivery
ON (delivery.uid = movement.delivery_uid)
LEFT JOIN stock
ON (stock.uid = category.uid
AND ((stock.node_uid = <dtml-var "portal_categories.site.Stock_MP.Gravelines.getUid()">
AND stock.quantity < 0)
OR (delivery.portal_type <> "Production Packing List" AND delivery.portal_type <> "Movement MP" )))
WHERE item.portal_type = "Piece Tissu"
AND stock.uid IS NULL
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params>sort_on
resource_id_list=""
variante_id_list=""
id
default_source_title
default_source_reference</params>
SELECT DISTINCT
item.uid, item.id, item.path, item.Description, item.simulation_state, item.default_destination_title
FROM
catalog AS item
<dtml-if expr="_.len(resource_id_list)>0">
, catalog AS resource
, category AS cat1
</dtml-if>
<dtml-if expr="_.len(variante_id_list)>0">
, catalog as variante
, category AS cat2
</dtml-if>
LEFT JOIN category
ON (category.category_uid=item.uid
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.getUid()">)
LEFT JOIN stock
ON (stock.uid = category.uid)
WHERE
item.portal_type = "Piece Tissu"
AND stock.node_uid = <dtml-var "portal_categories.site.Stock_MP.Gravelines.getUid()">
AND stock.quantity > 0
<dtml-in PieceTissu_searchConsumedList>AND item.uid <> <dtml-sqlvar uid type="int">
</dtml-in>
<dtml-if expr="_.len(resource_id_list)>0">
AND ( resource.id LIKE "<dtml-var expr="resource_id_list[0]">"
<dtml-in prefix="loop" expr="_.range(_.len(resource_id_list)-1)">
OR resource.id LIKE "<dtml-var expr="resource_id_list[loop_item+1]">"
</dtml-in>
)
AND cat1.uid=item.uid
AND cat1.category_uid=resource.uid
AND cat1.base_category_uid=<dtml-var "portal_categories.resource.uid">
</dtml-if>
<dtml-if expr="_.len(variante_id_list)>0">
AND ( variante.id LIKE "<dtml-var expr="variante_id_list[0]">"
<dtml-in prefix="loop" expr="_.range(_.len(variante_id_list)-1)">
OR variante.id LIKE "<dtml-var expr="variante_id_list[loop_item+1]">"
</dtml-in>
)
AND cat2.uid=item.uid
AND cat2.category_uid=variante.uid
AND cat2.base_category_uid=<dtml-var "portal_categories.coloris.uid">
</dtml-if>
<dtml-if id>
AND item.id LIKE <dtml-sqlvar id type="string">
</dtml-if>
<dtml-if default_source_title>
AND item.default_source_title LIKE <dtml-sqlvar default_source_title type="string">
</dtml-if>
<dtml-if default_source_reference>
AND item.default_source_reference LIKE <dtml-sqlvar default_source_reference type="string">
</dtml-if>
<dtml-if sort_on>ORDER BY
<dtml-var sort_on>
</dtml-if>
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:
class_file:
</dtml-comment>
<params></params>
SELECT DISTINCT
count(distinct item.uid)
FROM
catalog AS item
LEFT JOIN category
ON (category.category_uid=item.uid
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.getUid()">)
LEFT JOIN stock
ON (stock.uid = category.uid
AND stock.node_uid = <dtml-var "portal_categories.site.Stock_MP.Gravelines.getUid()">
AND stock.quantity < 0)
WHERE item.portal_type = "Piece Tissu"
AND category.uid IS NULL
AND item.id = "41347"
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT DISTINCT
count(distinct item.uid)
FROM
catalog AS item
LEFT JOIN category
ON (category.category_uid=item.uid
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.getUid()">)
LEFT JOIN stock
ON (stock.uid = category.uid
AND stock.node_uid = <dtml-var "portal_categories.site.Stock_MP.Gravelines.getUid()">
AND stock.quantity < 0)
LEFT JOIN stock AS stock_catalog
ON (stock.uid = stock_catalog.uid)
LEFT JOIN category AS other_category
ON (other_category.category_uid=item.uid
AND other_category.base_category_uid = <dtml-var "portal_categories.aggregate.getUid()">
AND other_category.uid <> category.uid)
LEFT JOIN stock AS other_stock
ON (other_stock.uid = other_category.uid
AND NOT (other_stock.node_uid = <dtml-var "portal_categories.site.Stock_MP.Gravelines.getUid()">
AND other_stock.quantity < 0))
LEFT JOIN category AS other_category2
ON (other_category2.category_uid=item.uid
AND other_category2.base_category_uid = <dtml-var "portal_categories.aggregate.getUid()">
AND other_category2.uid <> category.uid
AND other_category2.uid <> other_category.uid)
LEFT JOIN stock AS other_stock2
ON (other_stock2.uid = other_category.uid
AND NOT (other_stock2.node_uid = <dtml-var "portal_categories.site.Stock_MP.Gravelines.getUid()">
AND other_stock2.quantity < 0))
WHERE item.portal_type = "Piece Tissu"
AND stock_catalog.uid IS NULL
AND other_stock.uid IS NULL
AND other_stock2.uid IS NULL
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT DISTINCT
count(distinct item.uid)
FROM
catalog AS item
LEFT JOIN category
ON (category.category_uid=item.uid
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.getUid()">)
LEFT JOIN stock
ON (stock.uid = category.uid
AND stock.node_uid = <dtml-var "portal_categories.site.Stock_MP.Gravelines.getUid()">
AND stock.quantity < 0)
LEFT JOIN category AS other_category
ON (other_category.category_uid=item.uid
AND other_category.base_category_uid = <dtml-var "portal_categories.aggregate.getUid()">
AND category.uid <> other_category.uid)
LEFT JOIN stock AS other_stock
ON (other_stock.uid = other_category.uid
AND other_stock.node_uid = <dtml-var "portal_categories.site.Stock_MP.Gravelines.getUid()">
AND other_stock.quantity < 0)
LEFT JOIN category AS other_category2
ON (other_category.category_uid=item.uid
AND other_category.base_category_uid = <dtml-var "portal_categories.aggregate.getUid()">
AND category.uid <> other_category2.uid
AND other_category.uid <> other_category2.uid)
LEFT JOIN stock AS other_stock2
ON (other_stock2.uid = other_category2.uid
AND other_stock2.node_uid = <dtml-var "portal_categories.site.Stock_MP.Gravelines.getUid()">
AND other_stock2.quantity < 0)
WHERE item.portal_type = "Piece Tissu"
AND stock.uid IS NULL
AND other_stock.uid IS NULL
AND other_stock2.uid IS NULL
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:DeliveryListBrain
class_file:InventoryBrain.py
</dtml-comment>
<params>simulation_state:list
target_start_date
target_stop_date
query
node_title
resource_title
variation_text
sort_on
resource_tree</params>
SELECT
SUM(movement.target_quantity) as target_quantity,
movement.variation_text AS variation_text,
node.title AS node_title,
resource.title AS resource_title,
resource.uid AS resource_uid,
resource.relative_url AS resource_relative_url,
movement.target_start_date AS target_start_date,
movement.target_stop_date AS target_stop_date
<dtml-if query>, <dtml-sqlvar query type="string"> AS query </dtml-if>
FROM
catalog, movement, catalog AS resource, catalog AS node, catalog AS delivery <dtml-if query>, category </dtml-if>
WHERE
catalog.uid = movement.uid
AND movement.has_cell_content = 0
AND node.uid = movement.source_uid
AND movement.delivery_uid = delivery.uid
AND movement.target_quantity <> 0.0
AND delivery.portal_type = "Purchase Order"
AND movement.resource_uid = resource.uid
<dtml-if simulation_state> AND (<dtml-in simulation_state> catalog.simulation_state = <dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else> OR </dtml-if></dtml-in>)
</dtml-if><dtml-if target_start_date> AND movement.target_start_date < <dtml-sqlvar target_start_date type="string">
</dtml-if><dtml-if target_stop_date> AND movement.target_stop_date < <dtml-sqlvar target_stop_date type="string">
</dtml-if><dtml-if query> AND <dtml-if resource_tree>resource.uid = category.uid <dtml-else>movement.destination_uid = category.uid </dtml-if>
AND <dtml-var query>
</dtml-if><dtml-if node_title>AND node.title LIKE '%<dtml-var node_title>%'
</dtml-if><dtml-if resource_title>AND resource.title LIKE '%<dtml-var resource_title>%'
</dtml-if><dtml-if variation_text>AND variation_text LIKE '%<dtml-var variation_text>%'
</dtml-if>
GROUP BY
movement.resource_uid, movement.variation_text
<dtml-if sort_on>
ORDER BY
<dtml-var sort_on>
<dtml-else>
ORDER BY
movement.target_stop_date
</dtml-if>
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params>state_list=""
group_list=""
sort_on</params>
SELECT DISTINCT catalog.id, catalog.uid, catalog.relative_url, catalog.path, catalog.Description, catalog.simulation_state, catalog.default_destination_title
FROM catalog
<dtml-if expr="_.len(group_list)>0 and not ('' in group_list)">
, catalog AS organigramme
, category AS cat1
</dtml-if>
<dtml-if expr="_.len(group_list)>0 and '' in group_list">
LEFT JOIN category AS cat2 ON (cat2.uid=catalog.uid
AND cat2.base_category_uid=<dtml-var "portal_categories.group.uid">)
</dtml-if>
WHERE catalog.portal_type = "Sales Order"
<dtml-if expr="_.len(group_list)>0 and not ('' in group_list)">
AND ( organigramme.title LIKE "<dtml-var expr="group_list[0]">"
<dtml-in prefix="loop" expr="_.range(_.len(group_list)-1)">
OR organigramme.title LIKE "<dtml-var expr="group_list[loop_item+1]">"
</dtml-in>
)
AND cat1.uid=catalog.uid
AND cat1.category_uid=organigramme.uid
AND cat1.base_category_uid=<dtml-var "portal_categories.group.uid">
</dtml-if>
<dtml-if expr="_.len(state_list)>0">
AND ( catalog.simulation_state = "<dtml-var expr="state_list[0]">"
<dtml-in prefix="loop" expr="_.range(_.len(state_list)-1)">
OR catalog.simulation_state = "<dtml-var expr="state_list[loop_item+1]">"
</dtml-in>
)
</dtml-if>
<dtml-if expr="_.len(group_list)>0 and '' in group_list">
AND cat2.uid IS NULL
</dtml-if>
<dtml-if sort_on>
ORDER BY <dtml-var sort_on>
</dtml-if>
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params>state_list=""
group_list=""
sort_on</params>
SELECT DISTINCT catalog.id, catalog.uid, catalog.relative_url, catalog.path, catalog.Description, catalog.simulation_state, catalog.default_destination_title
FROM catalog, catalog AS catalog_order, category AS category_order
<dtml-if expr="_.len(group_list)>0 and not ('' in group_list)">
, catalog AS organigramme
, category AS cat1
</dtml-if>
<dtml-if expr="_.len(group_list)>0 and '' in group_list">
LEFT JOIN category AS cat2 ON (cat2.uid=order_catalog.uid
AND cat2.base_category_uid=<dtml-var "portal_categories.group.uid">)
</dtml-if>
WHERE catalog.portal_type = "Sales Packing List"
AND category_order.uid = catalog.uid
AND category_order.base_category_uid=<dtml-var "portal_categories.causality.uid">
AND category_order.category_uid = catalog_order.uid
AND catalog_order.portal_type = "Sales Order"
<dtml-if expr="_.len(group_list)>0 and not ('' in group_list)">
AND ( organigramme.title LIKE "<dtml-var expr="group_list[0]">"
<dtml-in prefix="loop" expr="_.range(_.len(group_list)-1)">
OR organigramme.title LIKE "<dtml-var expr="group_list[loop_item+1]">"
</dtml-in>
)
AND cat1.uid=catalog_order.uid
AND cat1.category_uid=organigramme.uid
AND cat1.base_category_uid=<dtml-var "portal_categories.group.uid">
</dtml-if>
<dtml-if expr="_.len(state_list)>0">
AND ( catalog.simulation_state = "<dtml-var expr="state_list[0]">"
<dtml-in prefix="loop" expr="_.range(_.len(state_list)-1)">
OR catalog.simulation_state = "<dtml-var expr="state_list[loop_item+1]">"
</dtml-in>
)
</dtml-if>
<dtml-if expr="_.len(group_list)>0 and '' in group_list">
AND cat2.uid IS NULL
</dtml-if>
<dtml-if sort_on>
ORDER BY <dtml-var sort_on>
</dtml-if>
\ No newline at end of file
<?xml version="1.0" encoding="iso-8859-1"?>
<form>
<title>Productions</title>
<name>ProductionOrder_inventoryView</name>
<action></action>
<enctype></enctype>
<method>POST</method>
<pt>form_view</pt>
<groups>
<group>
<title>left</title>
<fields>
<field><id>my_id</id> <type>StringField</type>
<values>
<alternate_name></alternate_name>
<css_class></css_class>
<default></default>
<description></description>
<display_maxwidth></display_maxwidth>
<display_width type="int">20</display_width>
<external_validator></external_validator>
<extra></extra>
<hidden type="int">0</hidden>
<max_length></max_length>
<required type="int">1</required>
<title>Id</title>
<truncate type="int">0</truncate>
</values>
<tales>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
<message name="required_not_found">Input is required but no input given.</message>
<message name="too_long">Too much input was given.</message>
</messages>
</field>
</fields>
</group>
<group>
<title>right</title>
<fields>
</fields>
</group>
<group>
<title>center</title>
<fields>
</fields>
</group>
<group>
<title>bottom</title>
<fields>
<field><id>listbox</id> <type>ListBox</type>
<values>
<all_columns type="list">[]</all_columns>
<all_editable_columns type="list">[]</all_editable_columns>
<alternate_name></alternate_name>
<columns type="list">[('node_title', 'Stock'), ('section_title', 'Propri\xe9taire'), ('resource_relative_url', 'Composant'), ('variation_text', 'Variante'), ('quantity', 'Qt\xe9'), ('getCurrentInventory', 'Stock'), ('getAvailableInventory', 'Dispo'), ('getFutureInventory', 'Futur'), ('getQuantityUnit', 'Unit\xe9')]</columns>
<css_class></css_class>
<default></default>
<default_params type="list">[]</default_params>
<description></description>
<domain_root_list type="list">[('portal_categories/site/Stock_MP', 'Stocks MP'), ('portal_categories/site', 'Sites')]</domain_root_list>
<domain_tree type="int">0</domain_tree>
<editable_columns type="list">[]</editable_columns>
<external_validator></external_validator>
<global_attributes type="list">[]</global_attributes>
<hidden type="int">0</hidden>
<lines type="int">20</lines>
<list_action>Resource_inventoryView</list_action>
<list_method type="method">ProductionOrder_getAggregatedMaterialProductionList</list_method>
<meta_types type="list">[]</meta_types>
<portal_types type="list">[]</portal_types>
<report_root_list type="list">[]</report_root_list>
<report_tree type="int">0</report_tree>
<search type="int">0</search>
<search_columns type="list">[]</search_columns>
<select type="int">0</select>
<selection_name>resource_current_inventory</selection_name>
<sort type="list">[]</sort>
<stat_method></stat_method>
<title>Productions</title>
</values>
<tales>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
</messages>
</field>
<field><id>current_inventory_chart</id> <type>ZGDChart</type>
<values>
<alternate_name></alternate_name>
<bg_transparent type="int">1</bg_transparent>
<chart_style>line_2d</chart_style>
<chart_title>Prvisions</chart_title>
<css_class></css_class>
<data_method>getInventoryHistoryChart</data_method>
<default></default>
<default_params type="list">[]</default_params>
<description></description>
<external_validator></external_validator>
<hidden type="int">0</hidden>
<selection_name>resource_current_inventory_chart</selection_name>
<title>Prvisions</title>
<x_title></x_title>
<y_title></y_title>
</values>
<tales>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
</messages>
</field>
</fields>
</group>
<group>
<title>hidden</title>
<fields>
</fields>
</group>
</groups>
</form>
\ No newline at end of file
<?xml version="1.0" encoding="iso-8859-1"?>
<form>
<title>Liste des ordres de conditionnement</title>
<name>PackingOrder_list</name>
<action></action>
<enctype>multipart/form-data</enctype>
<method>POST</method>
<pt>form_list</pt>
<groups>
<group>
<title>Default</title>
<fields>
<field><id>listbox</id> <type>ListBox</type>
<values>
<all_columns type="list">[('id', 'OC'), ('Description', 'Description'), ('default_destination_section_title', 'Soci\xe9t\xe9'), ('default_source_title', 'Produit par'), ('default_destination_title', 'Livrer \xe0'), ('target_stop_date', 'Date livraison'), ('simulation_state', 'Etat'), ('discussion_state', 'Discussion')]</all_columns>
<all_editable_columns type="list">[]</all_editable_columns>
<alternate_name></alternate_name>
<columns type="list">[('id', 'OC'), ('Description', 'Description'), ('default_destination_section_title', 'Soci\xe9t\xe9'), ('default_source_title', 'Produit par'), ('default_destination_title', 'Livrer \xe0'), ('target_stop_date', 'Date livraison'), ('simulation_state', 'Etat'), ('discussion_state', 'Discussion')]</columns>
<css_class></css_class>
<default></default>
<default_params type="list">[('id', "''")]</default_params>
<description></description>
<domain_root_list type="list">[]</domain_root_list>
<domain_tree type="int">0</domain_tree>
<editable_columns type="list">[]</editable_columns>
<external_validator></external_validator>
<global_attributes type="list">[]</global_attributes>
<hidden type="int">0</hidden>
<lines type="int">30</lines>
<list_action>list</list_action>
<list_method type="method">portal_catalog</list_method>
<meta_types type="list">[]</meta_types>
<portal_types type="list">[('Packing Order', 'Packing Order')]</portal_types>
<report_root_list type="list">[]</report_root_list>
<report_tree type="int">0</report_tree>
<search type="int">1</search>
<search_columns type="list">[]</search_columns>
<select type="int">1</select>
<selection_name>packing_order_selection</selection_name>
<sort type="list">[('id', 'id')]</sort>
<stat_method></stat_method>
<title>Ordres de conditionnement</title>
</values>
<tales>
<list_method>python:here.getPortalObject().portal_skins.local_list_method[here.REQUEST.list_method_id]</list_method>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
</messages>
</field>
</fields>
</group>
</groups>
</form>
\ No newline at end of file
## Script (Python) "ActivityTool_activateAssetPriceUpdate"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
# Retrieve all resources and commit select
pf_resource_list = context.SimulationTool_zGetResourceList(portal_type=['Modele', 'Assortiment'])
mp_resource_list = context.SimulationTool_zGetResourceList(portal_type=['Tissu', 'Composant'])
context.portal_simulation.commitTransaction()
# Create a new active_process
active_process = context.portal_activities.newActiveProcess(title="Calcul de valorisation du stock")
# Activate updateAssetPrice for PF
commit = 100
for b in list(pf_resource_list)[0:] :
relative_url = b.relative_url
variation_text = b.variation_text
if relative_url not in (None, ''):
if variation_text not in (None, '') or b.portal_type != 'Modele':
print "##Calculate price for %s %s" % (b.relative_url, b.variation_text)
result = context.portal_simulation.activate(activity='SQLQueue', priority=3, active_process=active_process).updateAssetPrice(
relative_url, variation_text, "group/Coramy", "site/Stock_PF" )
#print repr(result)
else:
print "###Error variation for %s" % relative_url
#commit = commit -1
#if commit == 0:
# # Commit from time to time
# context.portal_simulation.commitTransaction()
# commit = 100
else:
print "###Error unknow resource '%s'" % b.relative_url
# Activate updateAssetPrice for MP
commit = 100
for b in list(mp_resource_list)[0:] :
relative_url = b.relative_url
variation_text = b.variation_text
if relative_url not in (None, ''):
if variation_text not in (None,):
print "##Calculate price for %s %s" % (b.relative_url, b.variation_text)
result = context.portal_simulation.activate(activity='SQLQueue', priority=3, active_process=active_process).updateAssetPrice(
relative_url, variation_text, "group/Coramy", "site/Stock_MP" )
#print repr(result)
else:
print "###Error variation for %s" % relative_url
#commit = commit -1
#if commit == 0:
# # Commit from time to time
# context.portal_simulation.commitTransaction()
# commit = 100
else:
print "###Error unknow resource '%s'" % b.relative_url
return printed
## Script (Python) "ERP5Site_getAssetList"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=group_by_node=0, group_by_section=0, group_by_variation=0
##title=
##
request = context.REQUEST
stock_MP = 0
stock_PF = 1
if stock_MP == 1 :
inventory_list = context.Resource_zGetStockMPInventoryList(calculate_asset=1,
node_category='site/Stock_MP', section_category='group/Coramy',
group_by_node=group_by_node, group_by_section=group_by_section,
group_by_variation=group_by_variation,
simulation_state=['delivered', 'started', 'stopped', 'invoiced','planned','getting_ready','confirmed','ready', 'ordered'])
print "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % ('Nature composant', 'Code composant', 'Variante', 'Quantite', 'Prix unitaire', 'Montant total', 'Type composant', 'Fournisseur')
for b in inventory_list:
if b.inventory <> 0 :
amount_object = b.getObject()
if amount_object is not None :
unit_price = amount_object.Amount_getSupplierPrice()
else :
unit_price = 0
# AS SOON AS POSSIBLE asset_price should be given by b.asset_price an not unit_price*b.inventory
if group_by_variation:
print "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (b.resource_relative_url.split('/')[0], b.resource_relative_url.split('/')[-1], b.variation_text.replace('\n', '-'),
str(b.inventory).replace('.',','), str(unit_price).replace('.',','), str(unit_price*b.inventory).replace('.',','), b.type_title, b.source_title)
else:
print "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (b.resource_relative_url.split('/')[0], b.resource_relative_url.split('/')[-1], '',
str(b.inventory).replace('.',','), str(unit_price).replace('.',','), str(unit_price*b.inventory).replace('.',','), b.type_title, b.source_title)
if stock_PF == 1 :
inventory_list = context.Resource_zGetStockPFInventoryList(calculate_asset=1,
node_category='site/Stock_PF', section_category='group/Coramy', collection_url='collection/2004/DIM',
group_by_node=group_by_node, group_by_section=group_by_section,
group_by_variation=group_by_variation, to_date = "2003/11/30",
section_uid=context.portal_categories.group.Coramy.uid,
simulation_state=['delivered', 'started', 'stopped', 'invoiced']) # FOR FUTURE INVNETORY add ,'planned','getting_ready','confirmed','ready', 'ordered'
print "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % ('Nature produit', 'Code produit', 'Variantes', 'Quantite', 'Prix unitaire', 'Montant total', 'Famille', 'Client')
for b in inventory_list:
if b.inventory <> 0 :
amount_object = b.getObject()
if amount_object is not None :
try :
pri = amount_object.Amount_getPri()
except :
pri = -99
else :
pri = 0
if group_by_variation:
print "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (b.resource_relative_url.split('/')[0], b.resource_relative_url.split('/')[-1], b.variation_text.replace('\n', '-'),
str(b.inventory).replace('.',','), str(pri).replace('.',','), str(b.inventory*pri).replace('.',','), b.famille_title, b.destination_title, b.section_title)
else:
print "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (b.resource_relative_url.split('/')[0], b.resource_relative_url.split('/')[-1], '',
str(b.inventory).replace('.',','), str(pri).replace('.',','), str(b.inventory*pri).replace('.',','), b.famille_title, b.destination_title, b.section_title)
request.RESPONSE.setHeader('Content-Type','application/text')
return printed
## Script (Python) "ERP5Site_transferOfProperty"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=to_date
##title=
##
## Warnings:
## Prints, but never reads 'printed' variable.
##
from Products.ERP5.Document import newTempMovement
from DateTime import DateTime
# Stock sourcing states
source_state_list = ('delivered', 'started', 'stopped', 'invoiced')
coef_marge_coramy = 1.35
# Default date
now_date = DateTime(DateTime().Date())
to_date = "2003/10/31"
# Get inventory list
inventory_list = context.Resource_zGetStockPFInventoryList(calculate_asset=1,
node_category='site/Stock_PF', section_category='group/Coramy',
collection_url='collection/2004/DIM',
group_by_node=0, group_by_section=1,
group_by_variation=1, to_date=to_date,
section_uid=context.portal_categories.group.Coramy.uid,
simulation_state=source_state_list)
# Commit SQL
context.portal_simulation.commitTransaction()
# build a dictionnary of quantity, variation
quantity_dict = {}
price_dict = {}
variation_dict = {}
for inventory_item in inventory_list:
movement = inventory_item.getObject()
if movement is not None:
key = (inventory_item.resource_relative_url, tuple(movement.getVariationCategoryList()))
if not (key in quantity_dict.keys()) :
quantity_dict[key] = {}
price_dict[key] = {}
quantity_dict[key][inventory_item.section_title] = inventory_item.inventory
price_dict[key][inventory_item.section_title] = movement.Amount_getPri()*coef_marge_coramy
variation_dict[key] = movement.getVariationCategoryList()
else:
pass
#LOG('WARNING',0,'None movement found')
# Find out which are the movements to create
to_create = []
for key in quantity_dict.keys() :
section_list = quantity_dict[key].keys()
if 'Coramy' in section_list :
if quantity_dict[key]['Coramy'] > 0 :
to_create.append(key)
movement_list = []
new_id = 0
# Create movements which are needed
for relative_url, variation_category_list in to_create:
# CHECK IF EXISTING ID
key = (relative_url, variation_category_list)
new_id += 1
movement = newTempMovement( context.portal_simulation , str(new_id) )
movement.edit( resource=relative_url )
movement.setVariationCategoryList( variation_category_list )
resource = movement.getResourceValue()
if resource is not None:
# Only order existing resources
stop_date = to_date
if resource.getPortalType() in ('Modele', 'Assortiment'):
source = 'site/Stock_PF/Gravelines'
source_section = 'group/Coramy'
destination_section = 'group/Coramy/BLS'
destination = 'site/Stock_PF/Gravelines'
else:
source = source_section = resource.getSource()
destination_section = 'group/Coramy'
destination = 'site/Stock_MP/Gravelines'
movement.edit(target_quantity = quantity_dict[key]['Coramy'],
price = price_dict[key]['Coramy'],
target_start_date = stop_date,
target_stop_date = stop_date,
source = source,
source_section = source_section,
destination_section = destination_section,
destination = destination,
quantity_unit = resource.getDefaultQuantityUnit())
print "Order %s %s quantity: %s" % (movement.getResource(), movement.getVariationText(), movement.getNetConvertedTargetQuantity())
movement_list.append(movement)
# Build Deliveries
root_group = context.portal_simulation.collectMovement(movement_list)
delivery_list = context.portal_simulation.buildDeliveryList(root_group)
# Update deliveries
for delivery in delivery_list :
# update the state of the created deliveries to 'confirmed'
delivery.confirm()
# update local_roles
delivery.assign_gestionaire_designe_roles(user_name = '')
return delivery_list
## Script (Python) "Inventory_inventoriateLocatedPieceTissu"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
item_list = context.zGetLocatedPieceTissuList()
cr = '\r'
tab = '\t'
report = "Inventaire"+tab+"Resource_variante"+tab+"Liste de pices"+cr
item_dict = {}
for item in item_list :
if not item.resource in item_dict.keys() :
item_dict[item.resource] = {}
if not item.variation in item_dict[item.resource].keys() :
item_dict[item.resource][item.variation] = []
item_dict[item.resource][item.variation].append(item.id)
for resource_key in item_dict.keys() :
for variation_key in item_dict[resource_key].keys() :
movement_list = context.Resource_zGetInventoryMovementList(resource_relative_url=resource_key,variation_relative_url=variation_key)
if len(movement_list) == 0 :
report += "pas d'inventaire"+tab+variation_key+tab+str(item_dict[resource_key][variation_key])+cr
else :
movement = movement_list[0].getObject()
if movement is not None :
movement.setItemIdList(item_dict[resource_key][variation_key])
report += movement.getRelativeUrl()+tab+variation_key+tab+str(item_dict[resource_key][variation_key])+cr
else:
report += "None"+tab+variation_key+tab+str(item_dict[resource_key][variation_key])+cr
request.RESPONSE.setHeader('Content-Type','application/text')
return report
## Script (Python) "Inventory_launchTissuInventoryBuilder"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
supplier_list = context.zGetTissuSupplierList()
cr = '\r'
tab = '\t'
report = "Cration d'inventaires en cours pour :" + cr
for supplier_item in supplier_list :
supplier = supplier_item.getObject()
if supplier is not None :
supplier.activate().Inventory_tissuInventoryBuilder(supplier_list=[supplier.getTitle(),])
report += supplier.getTitle()+cr
return report
## Script (Python) "Inventory_tissuInventoryBuilder"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=product_reference_list=[], supplier_list=[]
##title=Add Lines to an Inventory
##
inventory_line_portal_type = "Inventory MP Line"
product_list = []
if len(product_reference_list) > 0 :
product_list += product_reference_list
supplier_list = ['']
elif len(supplier_list) > 0 :
product_raw_list = context.Resource_sqlResourceSupplierSearch(supplier_title_list=supplier_list)
for product_item in product_raw_list :
product_list.append(product_item.title)
if len(product_list) > 0 :
# build the inventory
inventory_module = context.getPortalObject().inventaire_mp
for supplier in supplier_list :
# create inventory
new_inventory_id = str(inventory_module.generateNewId())
my_categories = ['destination/site/Stock_MP/Gravelines','destination_section/group/Coramy']
context.portal_types.constructContent(type_name = 'Inventory MP',
container = inventory_module,
id = new_inventory_id,
description = supplier,
start_date = DateTime(),
categories = my_categories)
inventory = inventory_module[new_inventory_id]
for line_product in product_list :
new_id = str(inventory.generateNewId())
inventory.portal_types.constructContent(type_name=inventory_line_portal_type,
container=inventory,
id=new_id)
inventory_line = inventory[new_id]
resource_list = context.portal_catalog(id=line_product, portal_type='Tissu')
if len(resource_list) > 0:
resource_value = resource_list[0].getObject()
if resource_value is not None:
if resource_value.getPortalType() == 'Tissu' :
my_variation_base_category_list = ['coloris']
else :
my_variation_base_category_list = []
inventory_line.edit(description=line_product ,
resource_value = resource_value,
variation_base_category_list = my_variation_base_category_list)
my_variation_category_list = []
for category_tuple in inventory_line.getVariationRangeCategoryItemList() :
my_variation_category_list.append(category_tuple[0])
inventory_line.setVariationCategoryList(my_variation_category_list)
else:
inventory_line.edit(description=line_product)
## Script (Python) "PieceTissu_resetTargetQuantityOnUnaggregatedMovementList"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=delivery_uid
##title=
##
movement_list = context.PieceTissu_zGetUnaggregatedTissuMovementList(uid=delivery_uid)
for movement_item in movement_list :
movement = movement_item.getObject()
if movement is not None:
movement.Movement_resetTargetQuantity()
<dtml-comment>
title:
connection_id:MySQL
max_rows:100000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params>uid</params>
SELECT DISTINCT delivery.relative_url, delivery.path, delivery.portal_type, movement.start_date, movement.quantity, movement.inventory, movement.stop_date, source_node.title as source_title, destination_node.title as destination_title
FROM catalog, catalog as piece_tissu, catalog as delivery, category, movement
LEFT JOIN catalog as source_node ON source_node.uid = movement.source_uid
LEFT JOIN catalog as destination_node ON destination_node.uid = movement.destination_uid
WHERE catalog.uid=category.uid
AND piece_tissu.uid = category.category_uid
AND piece_tissu.portal_type = "Piece Tissu"
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.uid">
AND movement.uid = catalog.uid
AND delivery.uid = movement.delivery_uid
<dtml-if uid>
AND piece_tissu.uid = <dtml-sqlvar uid type="int">
</dtml-if>
ORDER BY movement.stop_date DESC, movement.start_date DESC
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:100000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params>uid</params>
SELECT DISTINCT catalog.relative_url, catalog.path
FROM catalog, catalog as resource, catalog as delivery, movement
LEFT JOIN category
ON (category.uid=movement.uid
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.uid">)
WHERE movement.uid = catalog.uid
AND movement.target_quantity <> 0
AND category.uid IS NULL
AND movement.is_accountable = 1
AND resource.uid = movement.resource_uid
AND resource.portal_type = "Tissu"
AND delivery.uid = movement.delivery_uid
AND delivery.uid = <dtml-var uid>
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params>resource_relative_url
variation_relative_url</params>
SELECT inventory_cell.relative_url, inventory_cell.path, movement.start_date, movement.stop_date
FROM movement, catalog as inventory_cell, catalog as resource, catalog as variation, category as cat1, category as cat2, catalog as delivery, catalog as inventory_line
WHERE inventory_cell.portal_type = "Inventory Cell"
AND inventory_cell.uid = movement.uid
AND movement.resource_uid = resource.uid
AND resource.relative_url = "<dtml-var resource_relative_url>"
AND variation.relative_url = "<dtml-var variation_relative_url>"
AND delivery.portal_type = "Inventory MP"
AND delivery.uid = movement.delivery_uid
AND inventory_cell.parent_uid = inventory_line.uid
AND cat2.uid = inventory_cell.uid
AND cat2.base_category_uid = <dtml-var "portal_categories.coloris.uid">
AND cat2.category_uid = variation.uid
AND cat1.uid = inventory_line.uid
AND cat1.base_category_uid = <dtml-var "portal_categories.resource.uid">
AND cat1.category_uid = resource.uid
ORDER BY movement.stop_date DESC, movement.start_date DESC
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:20000
max_cache:100
cache_time:0
class_name:InventoryListBrain
class_file:InventoryBrain.py
</dtml-comment>
<params>resource_uid:list
resource:list
from_date
to_date
node_uid
section_uid
node
section
variation_text="XXX_marker"
node_category
section_category
resource_category
omit_simulation
omit_input
omit_output
simulation_state
query
calculate_asset:int=0
group_by_node:int=1
group_by_section:int=1
group_by_variation:int=1</params>
SELECT
SUM(stock.quantity) AS inventory,
<dtml-if "calculate_asset != 0"> SUM(stock.total_asset_price) AS asset_price, </dtml-if>
node.title AS node_title,
node.relative_url AS node_relative_url,
section.title AS section_title,
section.relative_url AS section_relative_url,
resource.title AS resource_title,
resource.relative_url AS resource_relative_url,
resource.uid AS resource_uid,
movement.variation_text AS variation_text,
type_compo.title AS type_title,
resource.default_source_title AS source_title,
MAX(catalog.path) AS path
FROM
movement
LEFT JOIN catalog AS resource ON (movement.resource_uid = resource.uid)
LEFT JOIN category as cat_type_compo ON (cat_type_compo.uid = resource.uid
AND cat_type_compo.category_strict_membership = 1
AND ( cat_type_compo.base_category_uid = <dtml-var "portal_categories.type_composant.uid">
OR cat_type_compo.base_category_uid = <dtml-var "portal_categories.motif.uid"> ) )
LEFT JOIN catalog AS type_compo ON (type_compo.uid = cat_type_compo.category_uid)
LEFT JOIN catalog ON (catalog.uid = movement.uid)
LEFT JOIN stock ON (stock.uid = movement.uid)
LEFT JOIN catalog AS node ON (stock.node_uid = node.uid)
LEFT JOIN catalog AS section ON (stock.section_uid = section.uid)
<dtml-if node_category>, catalog AS node_c, catalog AS node_bc, category AS node_membership </dtml-if> <dtml-if section_category>, catalog AS section_c, catalog AS section_bc, category AS section_membership</dtml-if> <dtml-if resource_category>, catalog AS resource_c, catalog AS resource_bc, category AS resource_membership </dtml-if> <dtml-if query>, category </dtml-if>
WHERE
1 = 1
<dtml-if resource>AND (<dtml-in resource> resource.relative_url = <dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else> OR </dtml-if></dtml-in>)
</dtml-if><dtml-if resource_uid>AND (<dtml-in resource_uid> movement.resource_uid = <dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if></dtml-in>)
</dtml-if>AND movement.is_accountable = 1
<dtml-if from_date>AND movement.stop_date >= <dtml-sqlvar from_date type="string">
</dtml-if><dtml-if to_date>AND movement.stop_date < <dtml-sqlvar to_date type="string">
</dtml-if><dtml-if node_uid>AND stock.node_uid = <dtml-sqlvar node_uid type="int">
</dtml-if><dtml-if section_uid>AND stock.section_uid = <dtml-sqlvar section_uid type="int">
</dtml-if><dtml-if "variation_text <> 'XXX_marker'">AND movement.variation_text = <dtml-sqlvar variation_text type="string">
</dtml-if><dtml-if node>AND node.relative_url = <dtml-sqlvar node type="string">
</dtml-if><dtml-if section>AND section.relative_url = <dtml-sqlvar section type="string">
</dtml-if><dtml-if node_category>AND node_c.relative_url = <dtml-sqlvar node_category type="string">
AND node_membership.category_uid = node_c.uid
AND node_membership.base_category_uid = node_bc.uid
AND node_membership.uid = node.uid
</dtml-if><dtml-if section_category>AND section_c.relative_url = <dtml-sqlvar section_category type="string">
AND section_membership.category_uid = section_c.uid
AND section_membership.base_category_uid = section_bc.uid
AND section_membership.uid = section.uid
</dtml-if><dtml-if resource_category>AND resource_c.relative_url = <dtml-sqlvar resource_category type="string">
AND resource_membership.category_uid = resource_c.uid
AND resource_membership.base_category_uid = resource_bc.uid
AND resource_membership.uid = resource.uid
</dtml-if><dtml-if omit_simulation>AND catalog.portal_type != "Simulation Movement"
</dtml-if><dtml-if omit_input>AND stock.quantity < 0
</dtml-if><dtml-if omit_output>AND stock.quantity > 0
</dtml-if><dtml-if simulation_state>AND (<dtml-in simulation_state> catalog.simulation_state = <dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else> OR </dtml-if></dtml-in>)
</dtml-if><dtml-if query>AND category.uid = node.uid
AND <dtml-var query></dtml-if>
AND catalog.uid is not NULL
AND resource.uid is not NULL
GROUP BY
<dtml-if group_by_node>stock.node_uid, </dtml-if><dtml-if group_by_section>stock.section_uid, </dtml-if>movement.resource_uid<dtml-if group_by_variation>, movement.variation_text</dtml-if>
ORDER BY
node.title, resource.title, movement.variation_text
\ No newline at end of file
<dtml-comment>
title:
connection_id:MySQL
max_rows:20000
max_cache:100
cache_time:0
class_name:InventoryListBrain
class_file:InventoryBrain.py
</dtml-comment>
<params>resource_uid:list
resource:list
from_date
to_date
node_uid
section_uid
node
section
variation_text="XXX_marker"
node_category
section_category
resource_category
omit_simulation
omit_input
omit_output
simulation_state
query
calculate_asset:int=0
group_by_node:int=1
group_by_section:int=1
group_by_variation:int=1
collection_url</params>
SELECT
SUM(stock.quantity) AS inventory,
<dtml-if "calculate_asset != 0"> SUM(stock.total_asset_price) AS asset_price, </dtml-if>
node.title AS node_title,
node.relative_url AS node_relative_url,
section.title AS section_title,
section.relative_url AS section_relative_url,
resource.title AS resource_title,
resource.relative_url AS resource_relative_url,
resource.uid AS resource_uid,
movement.variation_text AS variation_text,
famille.title AS famille_title,
resource.default_destination_title as destination_title,
MAX(catalog.path) AS path
FROM
movement
LEFT JOIN catalog AS resource ON (movement.resource_uid = resource.uid)
<dtml-if collection_url>
LEFT JOIN catalog AS my_collection ON (my_collection.relative_url = "<dtml-var collection_url>")
LEFT JOIN category as cat_collection ON (cat_collection.uid = resource.uid
AND cat_collection.category_uid = my_collection.uid
AND cat_collection.base_category_uid = <dtml-var "portal_categories.collection.uid"> )
</dtml-if>
LEFT JOIN category as cat_famille ON ( cat_famille.uid = resource.uid
AND cat_famille.category_strict_membership = 1
AND cat_famille.base_category_uid = <dtml-var "portal_categories.eip.uid"> )
LEFT JOIN catalog AS famille ON (famille.uid = cat_famille.category_uid)
LEFT JOIN catalog ON (catalog.uid = movement.uid)
LEFT JOIN stock ON (stock.uid = movement.uid)
LEFT JOIN catalog AS node ON (stock.node_uid = node.uid)
LEFT JOIN catalog AS section ON (stock.section_uid = section.uid)
<dtml-if node_category>, catalog AS node_c, catalog AS node_bc, category AS node_membership </dtml-if> <dtml-if section_category>, catalog AS section_c, catalog AS section_bc, category AS section_membership</dtml-if> <dtml-if resource_category>, catalog AS resource_c, catalog AS resource_bc, category AS resource_membership </dtml-if> <dtml-if query>, category </dtml-if>
WHERE
1 = 1
<dtml-if resource>AND (<dtml-in resource> resource.relative_url = <dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else> OR </dtml-if></dtml-in>)
</dtml-if><dtml-if resource_uid>AND (<dtml-in resource_uid> movement.resource_uid = <dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if></dtml-in>)
</dtml-if>AND movement.is_accountable = 1
<dtml-if from_date>AND movement.stop_date >= <dtml-sqlvar from_date type="string">
</dtml-if><dtml-if to_date>AND movement.stop_date < <dtml-sqlvar to_date type="string">
</dtml-if><dtml-if node_uid>AND stock.node_uid = <dtml-sqlvar node_uid type="int">
</dtml-if><dtml-if section_uid>AND stock.section_uid = <dtml-sqlvar section_uid type="int">
</dtml-if><dtml-if "variation_text <> 'XXX_marker'">AND movement.variation_text = <dtml-sqlvar variation_text type="string">
</dtml-if><dtml-if node>AND node.relative_url = <dtml-sqlvar node type="string">
</dtml-if><dtml-if section>AND section.relative_url = <dtml-sqlvar section type="string">
</dtml-if><dtml-if node_category>AND node_c.relative_url = <dtml-sqlvar node_category type="string">
AND node_membership.category_uid = node_c.uid
AND node_membership.base_category_uid = node_bc.uid
AND node_membership.uid = node.uid
</dtml-if><dtml-if section_category>AND section_c.relative_url = <dtml-sqlvar section_category type="string">
AND section_membership.category_uid = section_c.uid
AND section_membership.base_category_uid = section_bc.uid
AND section_membership.uid = section.uid
</dtml-if><dtml-if resource_category>AND resource_c.relative_url = <dtml-sqlvar resource_category type="string">
AND resource_membership.category_uid = resource_c.uid
AND resource_membership.base_category_uid = resource_bc.uid
AND resource_membership.uid = resource.uid
</dtml-if><dtml-if omit_simulation>AND catalog.portal_type != "Simulation Movement"
</dtml-if><dtml-if omit_input>AND stock.quantity < 0
</dtml-if><dtml-if omit_output>AND stock.quantity > 0
</dtml-if><dtml-if simulation_state>AND (<dtml-in simulation_state> catalog.simulation_state = <dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else> OR </dtml-if></dtml-in>)
</dtml-if><dtml-if query>AND category.uid = node.uid
AND <dtml-var query></dtml-if>
<dtml-if collection_url>
AND cat_collection.uid is not NULL
</dtml-if>
AND catalog.uid is not NULL
GROUP BY
<dtml-if group_by_node>stock.node_uid, </dtml-if><dtml-if group_by_section>stock.section_uid, </dtml-if>movement.resource_uid<dtml-if group_by_variation>, movement.variation_text</dtml-if>
ORDER BY
node.title, resource.title, movement.variation_text
\ No newline at end of file
## Script (Python) "SimulationTool_activateRequirementList"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
if 1:
# Erase existing auto_planned
order_list = context.portal_catalog(simulation_state="auto_planned", parent_uid=[context.ordre_fabrication.getUid()])
order_id_list = map(lambda x:x.id,order_list)
object_id_list = context.ordre_fabrication.objectIds()
order_id_list = filter(lambda x: x in object_id_list, order_id_list)
context.ordre_fabrication.deleteContent(order_id_list)
order_list = context.portal_catalog(simulation_state="auto_planned", parent_uid=[context.commande_achat.getUid()])
order_id_list = map(lambda x:x.id,order_list)
object_id_list = context.commande_achat.objectIds()
order_id_list = filter(lambda x: x in object_id_list, order_id_list)
context.commande_achat.deleteContent(order_id_list)
#return "Done"
def activateNodeSection(node_category, section_category):
# Stock sourcing states
source_state_list = ('auto_planned', 'planned', 'ordered', 'confirmed', 'getting_ready', 'ready', 'started', 'stopped', 'delivered', 'invoiced')
#source_state_list = None
result = ''
# Get inventory list
#inventory_list = context.SimulationTool_getGroupFutureInventoryList(simulation_state=source_state_list)
inventory_list = context.Resource_zGetInventoryList(simulation_state=source_state_list,
node_category="site/Stock_MP",
section_category="group/Coramy",
group_by_variation=1)
# Commit SQL
# context.portal_simulation.commitTransaction()
# Call PortalSimulation_buildRequirementOrder for each missing resource
for inventory_item in inventory_list:
if inventory_item.inventory < 0 and inventory_item.inventory is not None:
# We should use a queue here rather than a dict - OVERKILL
movement = inventory_item.getObject()
if movement is not None:
resource = movement.getResourceValue()
if resource is not None:
if resource.getPortalType() != "Assortiment":
# Only source negative stock
result = result + "Activate Build Order for %s for missing quantity %s" % (inventory_item.resource_relative_url, inventory_item.inventory)
resource.activate(priority=5).SimulationTool_buildRequirementOrder(resource=inventory_item.resource_relative_url,
node_category=node_category, section_category=section_category )
return result
print activateNodeSection("site/Stock_MP", "group/Coramy")
print activateNodeSection("site/Stock_PF", "group/Coramy")
return printed
## Script (Python) "SimulationTool_buildRequirementOrder"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=resource=None,node_category=None,section_category=None
##title=
##
from Products.ERP5.Document import newTempMovement
from DateTime import DateTime
# Stock sourcing states
source_state_list = ('auto_planned', 'planned', 'ordered', 'confirmed', 'getting_ready', 'ready', 'delivered', 'started', 'stopped', 'invoiced')
#source_state_list = None
# Default date
now_date = DateTime(DateTime().Date())
# Get inventory list
#inventory_list = context.SimulationTool_getGroupFutureInventoryList(resource=resource, simulation_state=source_state_list)
inventory_list = context.Resource_zGetInventoryList(resource=[resource],
simulation_state=source_state_list,
node_category=node_category,
section_category=section_category,
group_by_variation=1)
# Commit SQL
context.portal_simulation.commitTransaction()
# First, find out which resources are missing
# and build a dictionnary of quantity, variation
quantity_dict = {}
variation_dict = {}
for inventory_item in inventory_list:
if inventory_item.inventory < 0 and inventory_item.inventory is not None:
# Only source negative stock
movement = inventory_item.getObject()
if movement is not None:
key = (inventory_item.resource_relative_url, tuple(movement.getVariationCategoryList()))
quantity_dict[key] = - inventory_item.inventory
variation_dict[key] = movement.getVariationCategoryList()
else:
pass
#LOG('ZeroStockRule WARNING',0,'None movement found')
# Commit SQL
context.portal_simulation.commitTransaction()
# A list of resources to create
to_create = quantity_dict.keys()
variated_movement_list = []
movement_list = []
new_id = 0
# Create movements which are needed
for relative_url, variation_category_list in to_create:
# CHECK IF EXISTING ID
key = (relative_url, variation_category_list)
new_id += 1
movement = newTempMovement( context.portal_simulation , str(new_id) )
movement.edit( resource=relative_url )
movement.setVariationCategoryList( variation_category_list )
resource = movement.getResourceValue()
if resource is not None:
# Only order existing resources
stop_date = resource.getNextNegativeInventoryDate(variation_text = movement.getVariationText())
if stop_date is None: # This happens if we have a negative stock already
stop_date = now_date
if resource.getPortalType() in ('Modele',):
source = 'site/Piquage'
source_section = 'group/Coramy'
destination_section = 'group/Coramy'
destination = 'site/Stock_PF/Gravelines'
else:
source = source_section = resource.getSource()
destination_section = 'group/Coramy'
destination = 'site/Stock_MP/Gravelines'
movement.edit(target_quantity = quantity_dict[key],
target_start_date = stop_date,
target_stop_date = stop_date,
source = source,
source_section = source_section,
destination_section = destination_section,
destination = destination,
quantity_unit = resource.getDefaultQuantityUnit())
print "Order %s %s quantity: %s" % (movement.getResource(), movement.getVariationText(), movement.getNetConvertedTargetQuantity())
if movement.getVariationText() == "":
movement_list.append(movement)
else:
variated_movement_list.append(movement)
# Build Order for non variated items
root_group = context.portal_simulation.collectMovement(movement_list)
order_list = context.portal_simulation.buildOrderList(root_group)
# Build Order for variated items
root_group = context.portal_simulation.collectMovement(variated_movement_list)
variated_order_list = context.portal_simulation.buildOrderList(root_group)
# Update orders
for order in order_list + variated_order_list:
print "Confirm Order %s" % order.getRelativeUrl()
order.autoPlan()
order.purchase_order_apply_condition()
# Set local_roles
# what's the gestionaire of this order
user_name = ''
# are we on a sales order or puchase order ?
if order.getPortalType() == 'Sales Order' :
user_name = order.getSourceAdministrationTitle().replace(' ','_')
elif order.getPortalType() == 'Purchase Order' :
# This is an error probably XXX
user_name = order.getDestinationAdministrationPersonTitle()
if user_name is not None:
user_name = user_name.replace(' ','_')
if user_name in (None,'',' ','_') :
user_name = "AnimatriceAppros"
# update local_roles
order.assign_gestionaire_designe_roles(user_name = user_name)
return printed
## Script (Python) "SimulationTool_updateInventory"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
for b in context.SimulationTool_zGetSortedInventoryList():
print "#### Indexing Inventory %s ####" % b.relative_url
o = b.getObject()
if o is not None: o.activate(priority=4).recursiveImmediateReindexObject()
return printed
<dtml-comment>
title:
connection_id:MySQL
max_rows:100000
max_cache:0
cache_time:0
class_name:
class_file:
</dtml-comment>
<params>portal_type:list</params>
SELECT DISTINCT
catalog.relative_url AS relative_url,
catalog.portal_type AS portal_type,
movement.variation_text AS variation_text
FROM
movement, catalog
WHERE
catalog.uid = movement.resource_uid
AND movement.is_accountable = 1
<dtml-if portal_type>AND (<dtml-in portal_type> catalog.portal_type = <dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else> OR </dtml-if></dtml-in>
) </dtml-if>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Formes</title>
<link rel=stylesheet type="text/css" href="http://erp5.coramy.fr/coramy/thumbnail.css" />
</head>
<body tal:define="forme_list python:here.object_action_list(selection_name='gamme_list')">
<h1>Dessins techniques des formes slectionnes</h1>
<div class="container">
<tal:block tal:repeat="forme python:forme_list">
<div class="float" tal:define="dessin_list python:forme.contentValues(filter={'portal_type':'Dessin Technique'})">
<a href="/" tal:attributes="href python:forme.absolute_url()">
<tal:block tal:condition="python: len(dessin_list)>0">
<img class="image" src="logo.gif" alt="Dessin technique" tal:attributes="src python:dessin_list[0].absolute_url() + '?display=small&format=jpeg&resolution=150'" />
</tal:block>
<tal:block tal:condition="python: len(dessin_list)==0">
<p>Pas de dessin associ</p>
</tal:block>
<p tal:content="python:forme.getId()" />
</a>
</div>
</tal:block>
<hr />
</div>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Vetements</title>
<link rel=stylesheet type="text/css" href="http://erp5.coramy.fr/coramy/thumbnail.css" />
</head>
<body tal:define="vetement_list python:here.object_action_list(selection_name='vetement_selection')">
<h1>Dessins techniques des vtements slectionns</h1>
<div class="container">
<tal:block tal:repeat="vetement python:vetement_list">
<div class="float" tal:define="dessin_list python:vetement.contentValues(filter={'portal_type':'Dessin Technique'})">
<a href="/" tal:attributes="href python:vetement.absolute_url()">
<tal:block tal:condition="python: len(dessin_list)>0">
<img class="image" src="logo.gif" alt="Dessin technique" tal:attributes="src python:dessin_list[0].absolute_url() + '?display=small&format=jpeg&resolution=150'" />
</tal:block>
<tal:block tal:condition="python: len(dessin_list)==0">
<p>Pas de dessin associ</p>
</tal:block>
<p tal:content="python:vetement.getId()" />
</a>
</div>
</tal:block>
<hr />
</div>
</body>
</html>
<dtml-comment>
title:
connection_id:MySQL
max_rows:10000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params>uid</params>
select resource.relative_url, resource.path, resource.portal_type, resource.description from catalog, category, catalog as resource
where catalog.uid = category.category_uid
and category.uid = resource.uid
and category.base_category_uid = <dtml-var "portal_categories.specialise.uid">
and catalog.uid = <dtml-var uid>
and ( resource.portal_type = "Modele"
or resource.portal_type = "Variante Morphologique" )
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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