diff --git a/addons/product_margin/__init__.py b/addons/product_margin/__init__.py index 4edd4f91e3e..77821bbc692 100644 --- a/addons/product_margin/__init__.py +++ b/addons/product_margin/__init__.py @@ -18,7 +18,6 @@ # along with this program. If not, see . # ############################################################################## - import wizard import product_margin diff --git a/addons/product_margin/__terp__.py b/addons/product_margin/__terp__.py index b0e81f341a7..9272287371a 100644 --- a/addons/product_margin/__terp__.py +++ b/addons/product_margin/__terp__.py @@ -31,7 +31,7 @@ the report has several options to help you get the data you need. """, 'author': 'Tiny', 'depends': ['base', 'product', 'account'], - 'update_xml': ['product_margin_view.xml'], + 'update_xml': ['wizard/product_margin_view.xml','product_margin_view.xml'], 'demo_xml': [], 'installable': True, 'active': False, diff --git a/addons/product_margin/product_margin_view.xml b/addons/product_margin/product_margin_view.xml index 03dfbdf2280..91ab522d62a 100644 --- a/addons/product_margin/product_margin_view.xml +++ b/addons/product_margin/product_margin_view.xml @@ -1,15 +1,13 @@ - - - - - - - - - + + + + product.margin.graph product.product diff --git a/addons/product_margin/wizard/__init__.py b/addons/product_margin/wizard/__init__.py index 4e2ecc2e39a..e1f1680bccb 100644 --- a/addons/product_margin/wizard/__init__.py +++ b/addons/product_margin/wizard/__init__.py @@ -19,7 +19,7 @@ # ############################################################################## -import wizard_product_margin +import product_margin # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/product_margin/wizard/product_margin.py b/addons/product_margin/wizard/product_margin.py new file mode 100644 index 00000000000..4e499eba2a5 --- /dev/null +++ b/addons/product_margin/wizard/product_margin.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## +import time +from osv import osv +from osv import fields + +import netsvc +import time +from tools.translate import _ +class product_margin(osv.osv_memory): + ''' + Product Margin + ''' + _name = 'product.margin' + _description = 'Product Margin' + + def _action_open_window(self, cr, uid, ids, context): + """ + @summary: + + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: the account ID or list of IDs if we want more than one + + @return: + """ + mod_obj = self.pool.get('ir.model.data') + result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view') + id = mod_obj.read(cr, uid, result, ['res_id']) + cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.graph', 'graph')) + view_res3 = cr.fetchone()[0] + cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.form.inherit', 'form')) + view_res2 = cr.fetchone()[0] + cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.tree', 'tree')) + view_res = cr.fetchone()[0] + + #get the current product.margin object to obtain the values from it + product_margin_obj = self.browse(cr,uid,ids)[0] + + return { + 'name': _('Product Margins'), + 'context':{'date_from':product_margin_obj.from_date,'date_to':product_margin_obj.to_date,'invoice_state' : product_margin_obj.invoice_state}, + 'view_type': 'form', + "view_mode": 'tree,form,graph', + 'res_model':'product.product', + 'type': 'ir.actions.act_window', + 'views': [(view_res,'tree'), (view_res2,'form'), (view_res3,'graph')], + 'view_id': False, + 'search_view_id': id['res_id'] + } + + def action_cancel(self, cr, uid, ids, context=None): + """ + @summary: + + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: the account ID or list of IDs if we want more than one + + @return: + """ + return {'type':'ir.actions.act_window_close'} + + _columns = { + #TODO : import time required to get currect date + 'from_date': fields.date('From'), + #TODO : import time required to get currect date + 'to_date': fields.date('To'), + 'invoice_state':fields.selection([ + ('paid','Paid'), + ('open_paid','Open and Paid'), + ('draft_open_paid','Draft, Open and Paid'), + ],'Invoice State', select=True, required=True), + } + _defaults = { + 'from_date': lambda *a:time.strftime('%Y-01-01'), + 'to_date': lambda *a:time.strftime('%Y-01-01'), + 'invoice_state': lambda *a:"open_paid", + } +product_margin() \ No newline at end of file diff --git a/addons/product_margin/wizard/product_margin_view.xml b/addons/product_margin/wizard/product_margin_view.xml new file mode 100644 index 00000000000..1d2a4746896 --- /dev/null +++ b/addons/product_margin/wizard/product_margin_view.xml @@ -0,0 +1,31 @@ + + + + + product.margin.form + product.margin + form + +
+ + + + + +