[IMP] product:convert the price_list wizard into osv_memory wizard

bzr revid: sbh@tinyerp.com-20100415092722-snzdrw61zoolk367
This commit is contained in:
sbh (Open ERP) 2010-04-15 14:57:22 +05:30
parent 5623ed5e8c
commit 3c0443a9d3
6 changed files with 102 additions and 72 deletions

View File

@ -49,13 +49,13 @@
'update_xml': [
'security/product_security.xml',
'security/ir.model.access.csv',
'wizard/product_price_view.xml',
'product_data.xml',
'product_report.xml',
'product_view.xml',
'pricelist_view.xml',
'partner_view.xml',
'company_view.xml',
'product_wizard.xml',
'process/product_process.xml'
],
'installable': True,

View File

@ -1,11 +0,0 @@
<?xml version="1.0" ?>
<openerp>
<data>
<wizard
id="report_wizard_price"
string="Price List"
model="product.product"
name="product.price_list"
keyword="client_print_multi"/>
</data>
</openerp>

View File

@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard_price
import product_price
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
from tools.translate import _
class product_price_list(osv.osv_memory):
_name = 'product.price_list'
_description = 'Product Price List'
_columns = {
'price_list': fields.many2one('product.pricelist', 'PriceList', required=True),
'qty1': fields.integer('Quantity-1'),
'qty2': fields.integer('Quantity-2'),
'qty3': fields.integer('Quantity-3'),
'qty4': fields.integer('Quantity-4'),
'qty5': fields.integer('Quantity-5'),
}
_defaults = {
'qty1': lambda *a: 0,
'qty2': lambda *a: 0,
'qty3': lambda *a: 0,
'qty4': lambda *a: 0,
'qty5': lambda *a: 0,
}
def print_report(self, cr, uid, ids, context=None):
"""
To get the date and print the report
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return : return report
"""
datas = {'ids': context.get('active_ids', [])}
res = self.read(cr, uid, ids, ['price_list','qty1', 'qty2','qty3','qty4','qty5'], context)
res = res and res[0] or {}
datas['form'] = res
return {
'type': 'ir.actions.report.xml',
'report_name': 'product.pricelist',
'datas': datas,
}
product_price_list()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Product Price List -->
<record id="view_product_price_list" model="ir.ui.view">
<field name="name">Price List</field>
<field name="model">product.price_list</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Price list">
<field name="price_list" />
<field name="qty1" colspan="2" />
<field name="qty2" colspan="2" />
<field name="qty3" colspan="2" />
<field name="qty4" colspan="2" />
<field name="qty5" colspan="2" />
<button icon='gtk-cancel' special="cancel"
string="Close" />
<button name="print_report" string="Print Report"
colspan="1" type="object" icon="gtk-print" />
</form>
</field>
</record>
<act_window id="action_product_price_list"
key2="client_action_multi" name="Price List"
res_model="product.price_list" src_model="product.product"
view_mode="form" target="new" view_type="form" />
</data>
</openerp>

View File

@ -1,59 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
qty1_form = '''<?xml version="1.0"?>
<form string="Price list">
<field name="price_list" />
<field name="qty1" colspan="2" />
<field name="qty2" colspan="2" />
<field name="qty3" colspan="2" />
<field name="qty4" colspan="2" />
<field name="qty5" colspan="2" />
</form>'''
qty1_fields = {
'price_list' : {'string' : 'PriceList', 'type' : 'many2one', 'relation' : 'product.pricelist', 'required':True },
'qty1': {'string':'Quantity-1', 'type':'integer', 'default':0},
'qty2': {'string':'Quantity-2', 'type':'integer', 'default':0},
'qty3': {'string':'Quantity-3', 'type':'integer', 'default':0},
'qty4': {'string':'Quantity-4', 'type':'integer', 'default':0},
'qty5': {'string':'Quantity-5', 'type':'integer', 'default':0},
}
class wizard_qty(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':qty1_form, 'fields':qty1_fields, 'state':[('end','Cancel'),('price','Print')]}
},
'price': {
'actions': [],
'result': {'type':'print', 'report':'product.pricelist', 'state':'end'}
}
}
wizard_qty('product.price_list')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: