1
##############################################################################
3
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
4
# Fabien Pinckaers <fp@tiny.Be>
6
# WARNING: This program as such is intended to be used by professional
7
# programmers who take the whole responsability of assessing all potential
8
# consequences resulting from its eventual inadequacies and bugs
9
# End users who are looking for a ready-to-use solution with commercial
10
# garantees and support are strongly adviced to contract a Free Software
13
# This program is Free Software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the Free Software
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
##############################################################################
35
_pricelist_form = '''<?xml version="1.0"?>
36
<form string="Upgrade list price">
37
<separator string="Select a pricelist " colspan="4"/>
38
<field name="pricelist" colspan="4" nolabel="1"/>
39
<separator string="Select Product Categories " colspan="4"/>
40
<field name="product_category" colspan="4" nolabel="1"/>
42
<field name="upgrade" />
45
_done_form = '''<?xml version="1.0"?>
46
<form string="Upgraded list price of prodcuts">
47
<field name="update_products"/>
52
'update_products': {'string':'Upgraded list price of Products', 'type':'float', 'readonly': True},
57
class wizard_product_pricelist(wizard.interface):
60
def _get_pricelist(self, cr, uid, context):
61
pricelist_obj=pooler.get_pool(cr.dbname).get('product.pricelist')
62
ids=pricelist_obj.search(cr, uid, [('type', '=', 'internal'),])
63
pricelists=pricelist_obj.browse(cr, uid, ids)
64
return [(pricelist.id, pricelist.name ) for pricelist in pricelists]
66
def _upgrade_listprice(self, cr, uid, data, context):
67
self.update_products=0
68
categories_ids=data['form']['product_category']
69
pricelist_obj=pooler.get_pool(cr.dbname).get('product.pricelist')
70
cat_obj = pooler.get_pool(cr.dbname).get('product.category')
71
product_obj = pooler.get_pool(cr.dbname).get('product.product')
72
pricelist_id=data['form']['pricelist']
74
def _upgrade(category_id):
75
if data['form']['upgrade']==True:
76
child_ids=cat_obj.search(cr, uid, [('parent_id', '=', category_id),])
77
for child_id in child_ids:
79
product_ids=product_obj.search(cr, uid, [('categ_id', '=', category_id),])
80
for product_id in product_ids:
81
list_price=pricelist_obj.price_get(cr, uid, [pricelist_id], product_id, 1)
82
product_obj.write(cr, uid, [product_id], {
83
'list_price': list_price[pricelist_id]})
84
self.update_products += 1
86
for category_id in categories_ids[0][2]:
89
return {'update_products':self.update_products}
92
'pricelist': {'string':'Pricelist', 'type':'many2one', 'relation': 'product.pricelist','domain':[('type','=','internal')], 'required':True},
93
'product_category': {'string':'Product Category', 'type':'many2many', 'relation': 'product.category', 'required':True},
94
'upgrade' : {'string':'Upgrade Child categories', 'type':'boolean', 'default': lambda x,y,z: True}
100
'result': {'type':'form', 'arch':_pricelist_form, 'fields':_pricelist_fields, 'state':[('end','Cancel'),('upgrade','Upgrade')]}
103
'actions':[_upgrade_listprice],
104
'result':{'type': 'form', 'arch': _done_form, 'fields': _done_fields,'state':[('end', 'End')]}
107
wizard_product_pricelist('product.listprice')
b'\\ No newline at end of file'