1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
5
# Fabien Pinckaers <fp@tiny.Be>
7
# WARNING: This program as such is intended to be used by professional
8
# programmers who take the whole responsability of assessing all potential
9
# consequences resulting from its eventual inadequacies and bugs
10
# End users who are looking for a ready-to-use solution with commercial
11
# garantees and support are strongly adviced to contract a Free Software
14
# This program is Free Software; you can redistribute it and/or
15
# modify it under the terms of the GNU General Public License
16
# as published by the Free Software Foundation; either version 2
17
# of the License, or (at your option) any later version.
19
# This program is distributed in the hope that it will be useful,
20
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
# GNU General Public License for more details.
24
# You should have received a copy of the GNU General Public License
25
# along with this program; if not, write to the Free Software
26
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
##############################################################################
30
from osv import osv, fields
32
class product_product(osv.osv):
33
_inherit = "product.product"
35
'package_weight': fields.float('Package Weight', digits=(16,2)),
38
'package_weight': lambda *args: 0.0
42
class crm_case_section(osv.osv):
43
_inherit = "crm.case.section"
45
'package_weight': fields.float('Package Weight', digits=(16,2)),
48
'package_weight': lambda *args: 0.0
52
class account_analytic_line_package(osv.osv):
53
_name = "account.analytic.line.package"
57
CREATE OR REPLACE VIEW account_analytic_line_package AS (
65
p.package_weight as unit_weight,
66
p.package_weight*l.unit_amount as total_weight,
69
account_analytic_line l
71
account_analytic_account a on (l.account_id=a.id)
73
product_product p on (p.id=l.product_id)
75
l.product_id is not null and
80
'name': fields.char('Name', size=128, readonly=True, select=1),
81
'date': fields.date('Date', readonly=True, select=1),
82
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
83
'account_id': fields.many2one('account.analytic.account', 'Account', readonly=True),
84
'product_id': fields.many2one('product.product', 'Product', select=2, readonly=True),
85
'unit_amount': fields.float('Quantity', readonly=True),
86
'unit_weight': fields.float('Unit Weight', readonly=True),
87
'total_weight': fields.float('Total Weight', readonly=True),
89
account_analytic_line_package()
91
class account_analytic_line_package_month(osv.osv):
92
_name = "account.analytic.line.package.month"
96
CREATE OR REPLACE VIEW account_analytic_line_package_month AS (
99
substring(l.date,0,8)||'-01' as name,
102
sum(p.package_weight*l.unit_amount) as total_weight,
103
sum(case when p.package_weight>0 then p.package_weight*l.unit_amount else 0 end) as total_activity,
104
sum(case when p.package_weight<0 then -p.package_weight*l.unit_amount else 0 end) as total_service
106
account_analytic_line l
108
account_analytic_account a on (l.account_id=a.id)
110
product_product p on (p.id=l.product_id)
112
l.product_id is not null and
117
substring(l.date,0,8)
121
'name': fields.date('Date', readonly=True, select=1),
122
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
123
'product_id': fields.many2one('product.product', 'Product', select=2, readonly=True),
124
'total_weight': fields.float('Total Weight', readonly=True),
125
'total_activity': fields.float('Total Activity', readonly=True),
126
'total_service': fields.float('Total Service', readonly=True),
128
account_analytic_line_package_month()