1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 # Copyright (C) 2010-2011 OpenERP S.A. (<http://www.openerp.com>).
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 ##############################################################################
24 from openerp.osv import fields, osv
27 class wizard_price(osv.osv):
28 _name = "wizard.price"
29 _description = "Compute price wizard"
31 'info_field': fields.text('Info', readonly=True),
32 'real_time_accounting': fields.boolean("Generate accounting entries when real-time"),
33 'recursive': fields.boolean("Change prices of child BoMs too"),
36 def default_get(self, cr, uid, fields, context=None):
37 res = super(wizard_price, self).default_get(cr, uid, fields, context=context)
38 product_pool = self.pool.get('product.product')
39 product_obj = product_pool.browse(cr, uid, context.get('active_id', False))
42 rec_id = context and context.get('active_id', False)
43 assert rec_id, _('Active ID is not set in Context.')
44 res['info_field'] = str(product_pool.compute_price(cr, uid, [product_obj.id], test=True, context=context))
47 def compute_from_bom(self, cr, uid, ids, context=None):
51 rec_id = context and context.get('active_id', False)
52 assert rec_id, _('Active ID is not set in Context.')
53 prod_obj = self.pool.get('product.product')
54 res = self.browse(cr, uid, ids, context=context)
55 prod = prod_obj.browse(cr, uid, rec_id, context=context)
56 prod_obj.compute_price(cr, uid, [prod.id], real_time_accounting=res[0].real_time_accounting, recursive=res[0].recursive, test=False, context=context)
58 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: