Commit 7d8e657f authored by Jérome Perrin's avatar Jérome Perrin

trade: display a summary of the product quantity on a packing list

Summary of total product quantity by product line.
parent 868f058b
......@@ -146,6 +146,7 @@ def getTaxLineList(order):\n
return tax_line_list\n
\n
line_base_contribution_list = []\n
quantity_unit_detail_dict = {}\n
number = 0\n
tax_free_line_totalprice = 0\n
line_list = []\n
......@@ -225,6 +226,30 @@ for line in getSubLineList(context):\n
tax_number=tax_number+\',\'+str(line_base_contribution_list.index(contribution)+1)\n
else:\n
tax_name=line.getBaseApplication()\n
\n
# Keep a mapping quantity_unit -> total quantity, to display total of products at the bottom.\n
# We keep the numeral value as `_total_quantity` and a method to convert this quantity\n
# to string for display using precision of the resource.\n
quantity_unit = line.getQuantityUnitTranslatedTitle() or (\n
line.getResource() and line.getResourceValue().getQuantityUnitTranslatedTitle()) or \'\'\n
\n
if quantity_unit:\n
# We only consider "physical" resources.\n
if line.getResourceValue().getPortalType() in (\'Product\', \'Component\'):\n
if quantity_unit in quantity_unit_detail_dict:\n
quantity_unit_detail = quantity_unit_detail_dict[quantity_unit]\n
quantity_unit_detail[\'_total_quantity\'] = quantity_unit_detail[\'_total_quantity\'] + line.getTotalQuantity()\n
else:\n
quantity_unit_detail = quantity_unit_detail_dict[quantity_unit] = {\n
"title": translateString("Total ${quantity_unit}", mapping={"quantity_unit": quantity_unit}),\n
"_total_quantity": line.getTotalQuantity(),\n
# We assume all resources for the same quantity unit have the same quantity precision.\n
# This is completly wrong, but should allow not to show decimal part for resources that are managed as "units"\n
"total_quantity_display_method": lambda qty: (\'%%.%df\' % line.getQuantityPrecisionFromResource(line.getResource())) % qty,\n
}\n
quantity_unit_detail["total_quantity"] = quantity_unit_detail["total_quantity_display_method"](\n
quantity_unit_detail["_total_quantity"])\n
\n
line_dict = {\n
\'style_name\': \'Table_20_Contents\',\n
\'left_style_name\': \'Table_20_Contents_20_Left\',\n
......
......@@ -533,6 +533,44 @@ AAA=</string> </value>
<text:p text:style-name=\'Table_20_Contents\'/>\n
</table:table-cell>\n
</table:table-row>\n
\n
<table:table-row table:style-name=\'Tableau3.2\'>\n
<table:table-cell table:style-name=\'Tableau3.A2\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\'/>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau3.A2\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\'/>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau3.A1\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\'/>\n
</table:table-cell>\n
<tal:block tal:condition="data_dict/quantity_unit_detail_list | nothing">\n
<table:table-cell table:number-columns-spanned="2" table:style-name=\'Tableau1.A2\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Item_20_Table_20_Title_20_Left\' i18n:translate="">Total Quantity of Products</text:p>\n
</table:table-cell>\n
<table:covered-table-cell/>\n
</tal:block>\n
</table:table-row>\n
<table:table-row table:style-name=\'Tableau3.2\' tal:repeat="quantity_unit_detail data_dict/quantity_unit_detail_list | python: []">\n
<table:table-cell table:style-name=\'Tableau3.A2\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\'/>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau3.A2\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\'/>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau3.A1\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\'/>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau3.D2\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Heading\'><span tal:replace=\'quantity_unit_detail/title\'/>:</text:p>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau3.E2\'\n
office:value-type=\'float\'\n
tal:attributes=\'office:value quantity_unit_detail/total_quantity\'>\n
<text:p text:style-name=\'Table_20_Contents_20_Right\' tal:content=\'quantity_unit_detail/total_quantity\'>800.000,00</text:p>\n
</table:table-cell>\n
</table:table-row>\n
\n
<table:table-row table:style-name=\'Tableau3.3\'>\n
<table:table-cell table:style-name=\'Tableau3.A2\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\'/>\n
......
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