Add quantity and forecast_quantity on product.template

This commit is contained in:
Cédric Krier
2008-10-31 14:14:36 +01:00
parent a715b693b9
commit 6ffb9684bc
+23 -2
View File
@@ -1,9 +1,30 @@
#This file is part of Tryton. The COPYRIGHT file at the top level
#of this repository contains the full copyright notices and license terms.
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from trytond.osv import fields, OSV
from trytond.wizard import Wizard, WizardOSV
import datetime
class Template(OSV):
_name = "product.template"
quantity = fields.Function('get_quantity', type='float', string='Quantity')
forecast_quantity = fields.Function('get_quantity', type='float',
string='Forecast Quantity')
def get_quantity(self, cursor, user, ids, name, args, context=None):
res = {}
if name not in ('quantity', 'forecast_quantity'):
raise Exception('Bad argument')
for template in self.browse(cursor, user, ids, context=context):
res[template.id] = 0.0
for product in template.products:
res[template.id] += product[name]
return res
Template()
class Product(OSV):
"Product"
_name = "product.product"