[Erp5-dev] Delivery getTotalPrice and getTotalQuantity

Alexandre Boeglin alex at nexedi.com
Tue Mar 15 11:38:50 CET 2005


Le Mardi 15 Mars 2005 10:28, Alexandre Boeglin a écrit :

> Please do not update ERP5/Document/Delivery to version 2.28 for now.

Okay, for the Delivery methods to work with buildSQLQuery, you'll need 
to modify this :

- in portal_skins/erp5_trade, replace Delivery_zGetTotal with the 
atached one,

- in portal_catalog/erp5_mysql add the (attached) 
z_related_resource_type method,

-in portal_catalog/erp5_mysql properties, add this line to 
sql_catalog_related_keys :

relatedResourceType | 
movement,catalog/portal_type/z_related_resource_type

Regards,
Alex
-------------- next part --------------
<dtml-comment>
title:
connection_id:erp5_sql_connection
max_rows:1000
max_cache:100
cache_time:0
class_name:
class_file:
</dtml-comment>
<params>uid
resource_uid
variation_text
from_table_list:list
where_expression
order_by_expression</params>
SELECT
	SUM(movement.quantity) AS inventory,
	SUM(movement.quantity) AS total_quantity,
	SUM(movement.total_price) AS total_price,
	SUM(movement.target_quantity) AS target_total_quantity,
	SUM(movement.target_total_price) AS target_total_price,
	AVG(movement.price) AS average_price

FROM
<dtml-in from_table_list> <dtml-var sequence-item> AS <dtml-var sequence-key><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in>

WHERE
1=1
<dtml-if where_expression> AND <dtml-var where_expression> </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>
<dtml-if variation_text> AND movement.variation_text = <dtml-sqlvar variation_text type="string"> </dtml-if>
 AND movement.is_accountable = 1
 AND catalog.portal_type <> "Container"
 AND catalog.portal_type <> "Simulation Movement"

<dtml-if order_by_expression>
ORDER BY <dtml-var order_by_expression>
</dtml-if>
-------------- next part --------------
<dtml-comment>
title:
connection_id:erp5_sql_connection
max_rows:1000
max_cache:100
cache_time:0
class_name:
class_file:
</dtml-comment>
<params>table_0
table_1</params>
<dtml-var table_0>.uid = catalog.uid
 AND <dtml-var table_1>.uid = <dtml-var table_0>.resource_uid


More information about the Erp5-dev mailing list