Commit 11e30046 authored by Rafael Monnerat's avatar Rafael Monnerat Committed by Łukasz Nowak

erp5_item: HTML5 PPL labels printout

parent 1f01f382
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_print</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_print</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>label_sheet_print</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Print Label Sheet</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Delivery_viewMovementItemListPrintDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: object.getSimulationState() in object.getPortalCurrentInventoryStateList()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Delivery_viewPrintMovementItemListAsHTML</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Delivery_viewMovementItemListPrintDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Delivery_viewMovementItemReportDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Print Label Sheet</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Delivery_viewPrintMovementItemListAsHTML</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html>
<head>
<link rel=stylesheet type=text/css tal:attributes="href python: here.getPortalObject().absolute_url() + '/item_barcode.css'">
</head>
<body tal:define="barcode_type python:request.get('barcode_type', 'code128');
barcode_per_line python:request.get('barcode_per_line', '5');
line_per_page python: 13">
<tal:block tal:repeat="item here/Delivery_getAggregatedItemValueList">
<tal:block tal:define="last python:(repeat['item'].number() % int(barcode_per_line)) == 0;
dummy python: context.REQUEST.set('last', int(last));">
<tal:block tal:replace="structure item/Item_viewAsLabel">
Item as Label
</tal:block>
<div class="newline"
tal:condition="last" > </div>
<div class="newpage"
tal:condition="python:(repeat['item'].number() % (int(line_per_page)*int(barcode_per_line))) == 0"> </div>
</tal:block>
</tal:block>
</body>
</html>
\ No newline at end of file
def getContext(context):
from Products.ERP5Type.Document import newTempMovement
# If this resource is variated, initialize the default
# variation context
variation_dict = {
'start_date': DateTime(),
'stop_date': DateTime() + 0.00001
}
if len(context.getVariationRangeCategoryList()):
request = context.REQUEST
# Set each category of variation either to the default value
# or to the value provided by the REQUEST object
for variation_base_category in context.getVariationBaseCategoryList():
default_variation = context.getVariationCategoryList(base_category_list=[variation_base_category])
# circumvent inconsistency for individual variations
default_variation = default_variation or \
context.getVariationRangeCategoryList(base_category_list=[variation_base_category])
if len(default_variation):
default_variation = default_variation[0]
variation_category = request.get(variation_base_category, default_variation)
variation_dict[variation_base_category] = variation_category
price_currency_value = context.getPriceCurrencyValue()
movement = newTempMovement(context, "temp_pricing_movement", resource_value=context,
price_currency_value=price_currency_value,
**variation_dict)
return movement
price = resource.getPrice(context=getContext(resource), supply_path_type=supply_path_type)
currency = resource.restrictedTraverse(resource.getSaleSupplyLinePriceCurrency()).getReference()
size_title = ""
variation_range_list = context.Item_getVariationRangeCategoryItemList()
for variation in context.Item_getVariationCategoryList():
if variation.startswith("size"):
variation_title_list = [i[0] for i in variation_range_list if i[1] == variation]
if len(variation_title_list):
size_title = variation_title_list[0]
break
if price is not None:
price_label = '%s %s' % (price, currency)
else:
price_label = ""
total = len(price_label) + 9 + len(size_title)
return price_label[0:len(price_label)*24 / total ] + ' - SIZE: ' + size_title[0:len(size_title)*24 / total ]
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>resource, supply_path_type</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Item_getLabelPrice</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
variation_title = ""
variation_range_list = context.Item_getVariationRangeCategoryItemList()
for variation in context.Item_getVariationCategoryList():
if variation.startswith("variation"):
variation_title_list = [i[0] for i in variation_range_list if i[1] == variation]
if len(variation_title_list):
variation_title = variation_title_list[0]
break
product_title = context.Item_getResourceTitle()
total = len(product_title) + 1 + len(variation_title)
return product_title[0:len(product_title)*24 / total ] +' ' + variation_title[0:len(variation_title)*24 / total ]
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Item_getLabelTitle</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Item_viewAsLabel</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<tal:block tal:define="barcode_type python:request.get('barcode_type', 'code128');
supply_path_type python:request.get('supply_path_type', 'Sale Supply Line');
resource here/Item_getResourceValue;
portal_title python: here.getPortalObject().getTitle();
last python:request.get('last', 0);
image_base_url python: here.getPortalObject().absolute_url() + '/Base_generateBarcodeImage?barcode_type=%s&data=%s'">
<div class="barcode not_last" tal:condition="python: not last">
<div class="barcode_header" tal:content="portal_title">
</div>
<div class="barcode_image">
<img src="" tal:attributes="src python: image_base_url % (barcode_type, here.getReference())" />
</div>
<br />
<div class="info">
<div class="item_reference" tal:content="here/getReference"> REFERENCE </div>
<div class="resource_title">
<span tal:content="here/Item_getLabelTitle"> Item Title </span>
<br />
<tal:block tal:condition="python: resource is not None">
<span tal:content="python: context.Item_getLabelPrice(resource, supply_path_type)"> Price </span>
</tal:block>
</div>
</div>
</div>
<div class="barcode last" tal:condition="last">
<div class="barcode_header" tal:content="portal_title">
</div>
<div class="barcode_image">
<img src="" tal:attributes="src python: image_base_url % (barcode_type, here.getReference())" />
</div>
<br />
<div class="info">
<div class="item_reference" tal:content="here/getReference"> REFERENCE </div>
<div class="resource_title">
<span tal:content="here/Item_getLabelTitle"> Item Title </span>
<br />
<tal:block tal:condition="python: resource is not None">
<span tal:content="python: context.Item_getLabelPrice(resource, supply_path_type)"> Price </span>
</tal:block>
</div>
</div>
</div>
</tal:block>
\ No newline at end of file
div.barcode {
text-align:center;
font-size: 6pt;
width: 38.1mm;
max-height: 21.4mm;
}
.resource_price,
.resource_title,
.item_number {
clear: both;
text-transform: uppercase;
}
div.barcode img {
width: 36.1mm;
max-height: 9mm;
}
div.barcode div.info {
margin-top: -3mm;
}
@page {
size: 210.0mm 297.0mm;
margin-top: 10.9mm;
margin-left: 0mm;
/* margin-left: 0mm; by rafael /*
margin-right: 0mm; /* by jps */
margin-bottom: 0mm;
}
body {
width: 210.0mm;
margin-left: 4.5mm;
}
div.barcode {
text-align:center;
float: left;
width: 36.0mm;
height: 21.1mm;
max-height:21.0mm;
/* margin-right: 6.0mm; rafael */
margin-right: 5.5mm;
margin-left: 0.9mm;
font-size: 6pt;
margin-bottom:1mm;
}
div.barcode.last {
/* margin-right: 0.0mm; */
margin-right: 0.0mm; /* by jps */
}
div.newline {
clear: both;
}
div.newpage {
page-break-after:always;
}
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="DTMLMethod" module="OFS.DTMLMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>item_barcode.css</string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -12,6 +12,7 @@ Purchase Order Line | item_creation
Purchase Order | aggregate_item
Purchase Packing List Line | item_creation
Purchase Packing List | aggregate_item
Purchase Packing List | label_sheet_print
Returned Purchase Packing List Line | item_creation
Returned Purchase Packing List | aggregate_item
Returned Sale Packing List Line | item_creation
......
......@@ -1183,6 +1183,12 @@ class TestItemScripts(ERP5TypeTestCase):
self.item.Item_getVariationRangeCategoryItemList(
at_date=DateTime() - 2))
def test_Item_getLabelPrice(self):
raise NotImplementedError
def test_Item_getLabelTitle(self):
raise NotImplementedError
def test_suite():
suite = unittest.TestSuite()
......
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