diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 8ac33b213bf..f13a0561076 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -399,7 +399,7 @@ class purchase_order_line(osv.osv): if not pricelist: raise osv.except_osv(_('No Pricelist !'), _('You have to select a pricelist in the purchase form !\nPlease set one before choosing a product.')) if not product: - return {'value': {'price_unit': 0.0, 'name':'','notes':''}, 'domain':{'product_uom':[]}} + return {'value': {'price_unit': 0.0, 'name':'','notes':'', 'product_uom' : False}, 'domain':{'product_uom':[]}} lang=False if partner_id: lang=self.pool.get('res.partner').read(cr, uid, [partner_id])[0]['lang'] diff --git a/addons/warning/__init__.py b/addons/warning/__init__.py new file mode 100644 index 00000000000..b26647e7ffb --- /dev/null +++ b/addons/warning/__init__.py @@ -0,0 +1,34 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# $Id$ +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import warning + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/warning/__terp__.py b/addons/warning/__terp__.py new file mode 100644 index 00000000000..db4a1616ac9 --- /dev/null +++ b/addons/warning/__terp__.py @@ -0,0 +1,44 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved. +# +# $Id$ +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +############################################################################### +{ + "name":"Module for Warnings form onchange Event", + "version":"1.0", + "author":"Tiny", + "category":"Tools", + "depends":["base","sale"], + "demo_xml":[], + "update_xml":[ + "warning_view.xml"], + "description": "Module for Warnings form onchange Event.", + "active":False, + "installable":True, +} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/warning/warning.py b/addons/warning/warning.py new file mode 100644 index 00000000000..19d070aa741 --- /dev/null +++ b/addons/warning/warning.py @@ -0,0 +1,184 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# $Id$ +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import time +from osv import fields,osv + +class res_partner(osv.osv): + _inherit = 'res.partner' + _columns = { + 'sale_warn' : fields.boolean('Sale Order'), + 'sale_warn_msg' : fields.char('Message for Sale Order', size=64), + 'purchase_warn' : fields.boolean('Purchase Order'), + 'purchase_warn_msg' : fields.char('Message for Purchase Order', size=64), + 'picking_warn' : fields.boolean('Stock Picking'), + 'picking_warn_msg' : fields.char('Message for Stock Picking', size=64), + 'invoice_warn' : fields.boolean('Invoice'), + 'invoice_warn_msg' : fields.char('Message for Invoice', size=64), + } +res_partner() + + +class sale_order(osv.osv): + _inherit = 'sale.order' + def onchange_partner_id(self, cr, uid, ids, part): + if not part: + return {'value':{'partner_invoice_id': False, 'partner_shipping_id':False, 'partner_order_id':False, 'payment_term' : False}} + warning = {} + partner = self.pool.get('res.partner').browse(cr, uid, part) + if partner.sale_warn: + warning={ + 'title': "Message", + 'message': partner.sale_warn_msg + } + result = super(sale_order, self).onchange_partner_id(cr, uid, ids, part)['value'] + return {'value': result, 'warning':warning} +sale_order() + + +class purchase_order(osv.osv): + _inherit = 'purchase.order' + def onchange_partner_id(self, cr, uid, ids, part): + if not part: + return {'value':{'partner_address_id': False}} + warning = {} + partner = self.pool.get('res.partner').browse(cr, uid, part) + if partner.purchase_warn: + warning={ + 'title': "Message", + 'message': partner.purchase_warn_msg + } + result = super(purchase_order, self).onchange_partner_id(cr, uid, ids, part)['value'] + return {'value': result, 'warning':warning} + +purchase_order() + + +class account_invoice(osv.osv): + _inherit = 'account.invoice' + def onchange_partner_id(self, cr, uid, ids, type, partner_id, + date_invoice=False, payment_term=False, partner_bank_id=False): + if not partner_id: + return {'value': { + 'address_contact_id': False , + 'address_invoice_id': False, + 'account_id': False, + 'payment_term': False, + } + } + warning = {} + partner = self.pool.get('res.partner').browse(cr, uid, partner_id) + if partner.invoice_warn: + warning={ + 'title': "Message", + 'message': partner.invoice_warn_msg + } + result = super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner_id, + date_invoice=False, payment_term=False, partner_bank_id=False)['value'] + return {'value': result, 'warning':warning} + +account_invoice() + +class stock_picking(osv.osv): + _inherit = 'stock.picking' + + def onchange_partner_in(self, cr, uid, context, partner_id=None): + if not partner_id: + return {} + partner = self.pool.get('res.partner.address').browse(cr, uid, [partner_id])[0].partner_id + warning = {} + if partner.picking_warn: + warning={ + 'title': "Message", + 'message': partner.picking_warn_msg + } + result = super(stock_picking, self).onchange_partner_in(cr, uid, context, partner_id) + return {'value': result, 'warning':warning} + +stock_picking() + +class product_product(osv.osv): + _inherit = 'product.product' + _columns = { + 'sale_line_warn' : fields.boolean('Sale Order Line'), + 'sale_line_warn_msg' : fields.char('Message for Sale Order Line', size=64), + 'purchase_line_warn' : fields.boolean('Purchase Order Line'), + 'purchase_line_warn_msg' : fields.char('Message for Purchase Order Line', size=64), + } +product_product() + +class sale_order_line(osv.osv): + _inherit = 'sale.order.line' + def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, + uom=False, qty_uos=0, uos=False, name='', partner_id=False, + lang=False, update_tax=True, date_order=False, packaging=False): + warning = {} + if not product: + return {'value': {'th_weight' : 0, 'product_packaging': False, + 'product_uos_qty': qty}, 'domain': {'product_uom': [], + 'product_uos': []}} + product_obj = self.pool.get('product.product') + product_info = product_obj.browse(cr, uid, product) + if product_info.sale_line_warn: + warning={ + 'title': "Message", + 'message': product_info.sale_line_warn_msg + } + + result = super(sale_order_line, self).product_id_change( cr, uid, ids, pricelist, product, qty=0, + uom=False, qty_uos=0, uos=False, name='', partner_id=False, + lang=False, update_tax=True, date_order=False, packaging=False)['value'] + return {'value': result, 'warning':warning} + +sale_order_line() + +class purchase_order_line(osv.osv): + _inherit = 'purchase.order.line' + def product_id_change(self,cr, uid, ids, pricelist, product, qty, uom, + partner_id, date_order=False): + warning = {} + if not product: + return {'value': {'price_unit': 0.0, 'name':'','notes':'', 'product_uom' : False}, 'domain':{'product_uom':[]}} + product_obj = self.pool.get('product.product') + product_info = product_obj.browse(cr, uid, product) + if product_info.purchase_line_warn: + warning={ + 'title': "Message", + 'message': product_info.purchase_line_warn_msg + } + + result = super(purchase_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty, uom, + partner_id, date_order=False)['value'] + return {'value': result, 'warning':warning} + +purchase_order_line() + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/warning/warning_view.xml b/addons/warning/warning_view.xml new file mode 100644 index 00000000000..769ddc8d5d2 --- /dev/null +++ b/addons/warning/warning_view.xml @@ -0,0 +1,46 @@ + + + + + + res.partner.warning.form.inherit + res.partner + form + + + + + + + + + + + + + + + + + + + + + product.warning.form.inherit + product.product + form + + + + + + + + + + + + + + +