[Erp5-dev] small feature for erp5_base

Bartek Gorny bartek at redpoint.mn.pl
Sat May 13 11:09:30 CEST 2006


Hello

I'd suggest that we add the script below to erp5_base, and respective
actions to coordinate portal types, like this:

Name:Set as default
Action:string:${object_url}/Coordinate_setAsDefault
Condition:python:object.getId()!='default_address'
Permission:Modify portal content
Category:object_action

Would make it much easier and faster for the user, and we'd save time
spent on explaining why they have to edit ids and how to do it :)

================

Coordinate_setAsDefault:

from Products.ERP5Type.Message import Message

defmap={'Address':'default_address','Email':'default_email','Fax':'default_fax','Telephone':'default_telephone'}

request=context.REQUEST
response=request.RESPONSE
id=context.getId()
entity=context.getParent()
me=context.absolute_url()
typ=context.getPortalType()

if id.startswith('default'):
  m=Message(domain='ui',message='This is the default')
  return response.redirect(me+'?portal_status_message='+str(m))

newid=context.generateNewId()
try:
  entity.manage_renameObject(defmap[typ],newid)
except AttributeError:
  pass

entity.manage_renameObject(id,defmap[typ])
m=Message(domain='ui',message='Ok, set as default')
return response.redirect(entity.absolute_url()+'/'+defmap[typ]+'/?portal_status_message='+str(m))

========================

Bartek



More information about the Erp5-dev mailing list