Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show images in the item_list printing #311

Open
kyholdings opened this issue Apr 21, 2013 · 0 comments
Open

How to show images in the item_list printing #311

kyholdings opened this issue Apr 21, 2013 · 0 comments

Comments

@kyholdings
Copy link

Hi

http://www.kyholdings.com/cms/allquotation/9010d61237be4bae86f3f38db9eb8543
http://www.kyholdings.com/cms/9010d61237be4bae86f3f38db9eb8543/OpenBareDocument?openwithform=quotation_printing

Here is the details I setting now:

the Images is a special field which I want to show image

field id: Images
Title: Images
Field Type: Rich text
Field moud: computed for display

formula:

db = context.getParentDatabase()
item_doc_id = context.getItem('ItemNo')
if not item_doc_id:
    return 0
item_doc = db.getDocument(item_doc_id)
images = asList(item_doc.getItem('image', []))
html ="" 
for image in images: 
  path_to_image = "http://www.kyholdings.com/image/plomino/"+image+".jpg" 
  html += """<a href="%(full)s"><img width="400" src="%(path)s" /></a>""" % {'path': path_to_image+"/image_preview", 'full': path_to_image+"/image_view_fullscreen"}
return html

Item list which I want to show the images(not text)

field id: Item_List
Title: Item List
Field Type: Rich text
Field moud: computed for display

formula:

db = context.getParentDatabase()
html="""<table border="0" width="100%">
    <colgroup>
        <col width="15%" />
        <col width="15%" />
        <col width="40%" />
        <col width="15%" />
        <col width="15%" />
    </colgroup>
    <tbody>
        """
item_list = context.getItem('Item_List', [])
for row in item_list:
    item_doc = db.getDocument(row[0])
    if not item_doc:
        html += "<tr><td>ERROR</td></tr>"
        continue
    html += """<tr><td><span style="font-family: verdana; font-size: 3px; ">%s</span></td><td><span style="font-family: verdana; font-size: 3px; ">%s</span></td><td><span style="font-family: verdana; font-size: 3px; ">%s</span></td><td><span style="font-family: verdana; font-size: 3px; ">%s</span></td><td style="text-align: center; "><span style="font-family: verdana; font-size: 3px; ">%s</span></td></tr>""" % (item_doc.getItem('ItemNo'), item_doc.getItem('NameEN')+item_doc.getItem('Packing')+str(item_doc.getItem('OPQTY'))+item_doc.getItem('QTYunitEN')+"/"+str(item_doc.getItem('Length'))+"x"+str(item_doc.getItem('Width'))+"x"+str(item_doc.getItem('High'))+"cm/"+str(item_doc.getItem('NW'))+"kgs/"+str(item_doc.getItem('GW'))+"kgs", item_doc.getItem('Images'), str(row[3]),  str(row[4]))
html += "</table>"
return html

It could work but could not show image.
Please help me to found solution with thanks.

Here is the link of the full setting and documents:

http://www.kyholdings.com/news/quotation-document/view
http://www.kyholdings.com/news/quotation-form-formula/view

Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant