~opencrea/+junk/export-lerelais

« back to all changes in this revision

Viewing changes to invoice_weight/report/sale_report.py

  • Committer: joannes
  • Date: 2018-06-07 17:04:22 UTC
  • Revision ID: joannes@debian-20180607170422-lntdx3d05n16r7vu
stat

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
            )""" % (self._table, self._select(), self._from(), self._group_by())
131
131
        #print sql
132
132
        self.env.cr.execute(sql)
 
133
 
 
134
 
 
135
"""
 
136
 
 
137
CREATE OR REPLACE VIEW view_account_invoice_total AS
 
138
SELECT
 
139
ai.sale_id AS order_id,
 
140
string_agg(ai.number, ' ') as invoice_list,
 
141
ai.date_invoice AS date,
 
142
max(partner_id) AS partner_id,
 
143
max(partner_shipping_id) AS partner_shipping_id,
 
144
max(warehouse_id) AS warehouse_id,
 
145
max(user_id) AS user_id,
 
146
sum(amount_untaxed_signed) AS amount_untaxed_signed
 
147
 
 
148
FROM account_invoice ai
 
149
WHERE type IN ('out_invoice', 'out_refund')
 
150
GROUP BY ai.date_invoice, ai.sale_id
 
151
 
 
152
 
 
153
 
 
154
 
 
155
            CREATE OR REPLACE VIEW view_sale_order_line_keys AS
 
156
 
 
157
             SELECT
 
158
                    l.order_id as order_id,
 
159
                    sum(l.stat_weight) as stat_weight,
 
160
                    sum(l.stat_ht) as stat_ht,
 
161
                    sum(l.stat_transport) as stat_transport,
 
162
                    sum(l.stat_total) as stat_total,
 
163
                    max(l.name) as name,
 
164
                    p.categ_id as categ_id
 
165
 
 
166
            FROM
 
167
                sale_order_line l
 
168
                left join product_product p on (l.product_id=p.id)
 
169
 
 
170
            GROUP BY
 
171
                    l.order_id,
 
172
                    p.categ_id
 
173
 
 
174
 
 
175
SELECT
 
176
vait.order_id AS order_id,
 
177
vait.invoice_list AS invoice_list,
 
178
vsolk.categ_id AS categ_id,
 
179
vsolk.stat_weight * vait.amount_untaxed_signed AS weight,
 
180
vsolk.stat_ht * vait.amount_untaxed_signed AS stat_ht,
 
181
vsolk.stat_transport * vait.amount_untaxed_signed AS stat_transport,
 
182
vsolk.stat_total * vait.amount_untaxed_signed AS stat_total
 
183
 
 
184
 
 
185
FROM view_account_invoice_total vait, view_sale_order_line_keys vsolk
 
186
WHERE vait.order_id = vsolk.order_id
 
187
UNION
 
188
negative price , weight...
 
189
UNION
 
190
no order_id
 
191
 
 
192
 
 
193
"""
 
 
b'\\ No newline at end of file'