75 |
wanted = rs.current.getField('parent') |
wanted = rs.current.getField('parent') |
76 |
|
|
77 |
# ids ahora es el array de herencia |
# ids ahora es el array de herencia |
78 |
sel = "SELECT prod._table AS id, code.code, prod.canonical_name AS name, coalesce(clas.name, 'sin clasificar') AS clas, coalesce(%s) AS price, coalesce(%s) AS format FROM _product_data prod INNER JOIN _product_code_data code ON (prod._table=code.product) LEFT JOIN _product_classification_data clas ON (prod.product_classification = clas._table) LEFT JOIN %s LEFT JOIN %s WHERE prod._end_t IS NULL AND code._end_t IS NULL AND clas._end_t IS NULL AND %s AND %s ORDER BY id" % ( |
sel = """ |
79 |
|
SELECT prod._table AS id, |
80 |
|
code.code, |
81 |
|
prod.canonical_name AS name, |
82 |
|
coalesce(clas.name, 'sin clasificar') AS clas, |
83 |
|
coalesce(%s, 0.0) AS price, |
84 |
|
coalesce(%s, '%%10.2f') AS format |
85 |
|
FROM _product_data AS prod |
86 |
|
INNER JOIN _product_code_data code |
87 |
|
ON (prod._table=code.product) |
88 |
|
LEFT JOIN _product_classification_data clas |
89 |
|
ON (prod.product_classification = clas._table) |
90 |
|
INNER JOIN _price_data AS price1 |
91 |
|
ON (prod._table = price1.product AND price1.price_type = 1) |
92 |
|
%s |
93 |
|
%s |
94 |
|
WHERE prod._end_t IS NULL |
95 |
|
AND code._end_t IS NULL |
96 |
|
AND clas._end_t IS NULL |
97 |
|
AND %s |
98 |
|
AND %s |
99 |
|
ORDER BY id |
100 |
|
""" % ( |
101 |
", ".join(["price%d.unit_price" % i for i in ids]), |
", ".join(["price%d.unit_price" % i for i in ids]), |
102 |
", ".join(["curr%d.format" % i for i in ids]), |
", ".join(["curr%d.format" % i for i in ids]), |
103 |
" LEFT JOIN ".join(["_price_data AS price%d ON (prod._table=price%d.product AND price%d.price_type = %d)" % (i, i, i, i) for i in ids]), |
"".join([" LEFT JOIN _price_data AS price%d\n ON (prod._table=price%d.product AND price%d.price_type = %d)\n" % (i, i, i, i) for i in ids[:-1]]), |
104 |
" LEFT JOIN ".join(["_currency_type_data AS curr%d ON (curr%d._table=price%d.currency_type)" % (i, i, i) for i in ids]), |
"".join([" LEFT JOIN _currency_type_data AS curr%d\n ON (curr%d._table=price%d.currency_type)\n" % (i, i, i) for i in ids]), |
105 |
" AND ".join(["price%d._end_t IS NULL" % i for i in ids]), |
" AND ".join(["price%d._end_t IS NULL" % i for i in ids]), |
106 |
" AND ".join(["curr%d._end_t IS NULL" % i for i in ids])) |
" AND ".join(["curr%d._end_t IS NULL" % i for i in ids])) |
107 |
|
|
128 |
if sorter: |
if sorter: |
129 |
prices[k].sort(sorter) |
prices[k].sort(sorter) |
130 |
for i in prices[k]: |
for i in prices[k]: |
131 |
r.add_dentry('item', product=i['name'], code=i['code'], price=(i['format'] or '%10.2f') % i['price']) |
r.add_dentry('item', product=i['name'], code=i['code'], price=(i['format']) % i['price']) |
132 |
r.close_detail() |
r.close_detail() |
133 |
|
|
134 |
printing.previewPrint([str(r)], gConfig('printcommand')) |
printing.previewPrint([str(r)], gConfig('printcommand')) |