+
+
+
+
+
+
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index 6c1c8148f8f..13d48317139 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -411,7 +411,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/sale/sale.py b/addons/sale/sale.py
index 4a52e8d4608..8833f8ffb89 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -301,7 +301,7 @@ class sale_order(osv.osv):
def _inv_get(self, cr, uid, order, context={}):
return {}
- def _make_invoice(self, cr, uid, order, lines, context={}):
+ def _make_invoice(self, cr, uid, order, lines,context={}):
a = order.partner_id.property_account_receivable.id
if order.payment_term:
pay_term = order.payment_term.id
@@ -770,10 +770,10 @@ class sale_order_line(osv.osv):
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={}
product_uom_obj = self.pool.get('product.uom')
partner_obj = self.pool.get('res.partner')
product_obj = self.pool.get('product.product')
-
if partner_id:
lang = partner_obj.browse(cr, uid, partner_id).lang
context = {'lang': lang, 'partner_id': partner_id}
@@ -781,7 +781,7 @@ class sale_order_line(osv.osv):
if not product:
return {'value': {'th_weight' : 0, 'product_packaging': False,
'product_uos_qty': qty}, 'domain': {'product_uom': [],
- 'product_uos': []}}
+ 'product_uos': []}}
if not date_order:
date_order = time.strftime('%Y-%m-%d')
@@ -792,9 +792,19 @@ class sale_order_line(osv.osv):
default_uom = product_obj.uom_id and product_obj.uom_id.id
pack = self.pool.get('product.packaging').browse(cr, uid, packaging, context)
q = product_uom_obj._compute_qty(cr, uid, uom, pack.qty, default_uom)
- qty = qty - qty % q + q
+# qty = qty - qty % q + q
+ if not (qty % q) == 0 :
+ ean = pack.ean
+ qty_pack = pack.qty
+ type_ul = pack.ul
+ warn_msg = "You selected a quantity of %d Units.\nBut it's not compatible with the selected packaging.\nHere is a proposition of quantities according to the packaging: " % (qty)
+ warn_msg = warn_msg + "\n\nEAN: " + str(ean) + " Quantiny: " + str(qty_pack) + " Type of ul: " + str(type_ul.name)
+ warning={
+ 'title':'Packing Information !',
+ 'message': warn_msg
+ }
result['product_uom_qty'] = qty
-
+
if uom:
uom2 = product_uom_obj.browse(cr, uid, uom)
if product_obj.uom_id.category_id.id <> uom2.category_id.id:
@@ -864,7 +874,7 @@ class sale_order_line(osv.osv):
# Round the quantity up
# get unit price
- warning={}
+
if not pricelist:
warning={
'title':'No Pricelist !',
@@ -884,11 +894,9 @@ class sale_order_line(osv.osv):
'message':
"Couldn't find a pricelist line matching this product and quantity.\n"
"You have to change either the product, the quantity or the pricelist."
- }
+ }
else:
- result.update({'price_unit': price})
-
-
+ result.update({'price_unit': price})
return {'value': result, 'domain': domain,'warning':warning}
def product_uom_change(self, cursor, user, ids, pricelist, product, qty=0,
diff --git a/addons/sale/stock.py b/addons/sale/stock.py
index 002caba90d5..9dafbc6ff1d 100644
--- a/addons/sale/stock.py
+++ b/addons/sale/stock.py
@@ -114,3 +114,4 @@ stock_picking()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/sale/stock_view.xml b/addons/sale/stock_view.xml
index f6cc1f1c03f..db273c38b60 100644
--- a/addons/sale/stock_view.xml
+++ b/addons/sale/stock_view.xml
@@ -15,4 +15,3 @@
-
diff --git a/addons/sale/wizard/make_invoice_advance.py b/addons/sale/wizard/make_invoice_advance.py
index 792a3d41da2..da1bfb04b65 100644
--- a/addons/sale/wizard/make_invoice_advance.py
+++ b/addons/sale/wizard/make_invoice_advance.py
@@ -94,7 +94,7 @@ def _createInvoices(self, cr, uid, data, context={}):
'invoice_line': [(6,0,create_ids)],
'currency_id' :sale.pricelist_id.currency_id.id,
'comment': '',
- 'payment_term':sale.partner_id.property_payment_term.id,
+ 'payment_term':sale.payment_term.id,
}
inv_obj = pool_obj.get('account.invoice')
inv_id = inv_obj.create(cr, uid, inv)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 30b48da5a03..7e518828615 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -497,7 +497,25 @@ class stock_picking(osv.osv):
self.pool.get('stock.move').force_assign(cr, uid, move_ids)
wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
return True
-
+
+ def draft_force_assign(self, cr, uid, ids, *args):
+ wf_service = netsvc.LocalService("workflow")
+ for pick in self.browse(cr, uid, ids):
+ wf_service.trg_validate(uid, 'stock.picking', pick.id,
+ 'button_confirm', cr)
+ move_ids = [x.id for x in pick.move_lines]
+ self.pool.get('stock.move').force_assign(cr, uid, move_ids)
+ wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
+ return True
+
+ def draft_validate(self, cr, uid, ids, *args):
+ wf_service = netsvc.LocalService("workflow")
+ self.draft_force_assign(cr, uid, ids)
+ for pick in self.browse(cr, uid, ids):
+ self.action_move(cr, uid, [pick.id])
+ wf_service.trg_validate(uid, 'stock.picking', pick.id , 'button_done', cr)
+ return True
+
def cancel_assign(self, cr, uid, ids, *args):
wf_service = netsvc.LocalService("workflow")
for pick in self.browse(cr, uid, ids):
@@ -607,7 +625,8 @@ class stock_picking(osv.osv):
invoice_line_obj = self.pool.get('account.invoice.line')
invoices_group = {}
res = {}
-
+ sale_line_obj = self.pool.get('sale.order.line')
+
for picking in self.browse(cursor, user, ids, context=context):
if picking.invoice_state != '2binvoiced':
continue
@@ -645,7 +664,51 @@ class stock_picking(osv.osv):
context=context)
invoices_group[partner.id] = invoice_id
res[picking.id] = invoice_id
-
+
+ sale_line_ids = sale_line_obj.search(cursor, user, [('order_id','=',picking.sale_id.id)])
+ sale_lines = sale_line_obj.browse(cursor, user, sale_line_ids, context=context)
+
+ for sale_line in sale_lines:
+ if sale_line.product_id.type == 'service' and sale_line.invoiced == False:
+ if group:
+ name = picking.name + '-' + sale_line.name
+ else:
+ name = sale_line.name
+ if type in ('out_invoice', 'out_refund'):
+ account_id = sale_line.product_id.product_tmpl_id.\
+ property_account_income.id
+ if not account_id:
+ account_id = sale_line.product_id.categ_id.\
+ property_account_income_categ.id
+ else:
+ account_id = sale_line.product_id.product_tmpl_id.\
+ property_account_expense.id
+ if not account_id:
+ account_id = sale_line.product_id.categ_id.\
+ property_account_expense_categ.id
+ price_unit = self._get_price_unit_invoice(cursor, user,
+ sale_line, type)
+ discount = self._get_discount_invoice(cursor, user, sale_line)
+ tax_ids = self._get_taxes_invoice(cursor, user, sale_line, type)
+ account_analytic_id = self._get_account_analytic_invoice(cursor,
+ user, picking, sale_line)
+
+ invoice_line_id = invoice_line_obj.create(cursor, user, {
+ 'name': name,
+ 'invoice_id': invoice_id,
+ 'uos_id': sale_line.product_uos.id or sale_line.product_uom.id,
+ 'product_id': sale_line.product_id.id,
+ 'account_id': account_id,
+ 'price_unit': price_unit,
+ 'discount': discount,
+ 'quantity': sale_line.product_uos_qty,
+ 'invoice_line_tax_id': [(6, 0, tax_ids)],
+ 'account_analytic_id': account_analytic_id,
+ }, context=context)
+ sale_line_obj.write(cursor, user, [sale_line.id], {'invoiced':True,
+ 'invoice_lines': [(6, 0, [invoice_line_id])],
+ })
+
for move_line in picking.move_lines:
if group:
name = picking.name + '-' + move_line.name
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index 54f46b5899c..22bed36de57 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -550,9 +550,10 @@
-
+
-
+
+
@@ -638,9 +639,10 @@
-
+
-
+
+
@@ -806,9 +808,10 @@
-
+
-
+
+
@@ -975,9 +978,10 @@
-
+
-
+
+
@@ -1264,4 +1268,3 @@
-
diff --git a/addons/stock/stock_wizard.xml b/addons/stock/stock_wizard.xml
index fa46831cf2c..4bbba3808d5 100644
--- a/addons/stock/stock_wizard.xml
+++ b/addons/stock/stock_wizard.xml
@@ -34,5 +34,13 @@
multi="True"
id="wizard_merge_inventory"/>
+
+
diff --git a/addons/stock/wizard/__init__.py b/addons/stock/wizard/__init__.py
index b18ad592fb3..0064614f005 100644
--- a/addons/stock/wizard/__init__.py
+++ b/addons/stock/wizard/__init__.py
@@ -37,8 +37,9 @@ import wizard_split_lot_line
import wizard_track_line
import wizard_ups
import wizard_invoice_onshipping
-import inventory_merge
+import wizard_move_by_location
+import wizard_inventory
import inventory_merge_zero
-
+import inventory_merge
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/wizard_inventory.py b/addons/stock/wizard/wizard_inventory.py
new file mode 100644
index 00000000000..f70b82b863d
--- /dev/null
+++ b/addons/stock/wizard/wizard_inventory.py
@@ -0,0 +1,113 @@
+##############################################################################
+#
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+# 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
+import wizard
+import ir
+import pooler
+from osv.osv import except_osv
+from osv import fields,osv
+import netsvc
+
+inventory_form = """
+
+"""
+
+inventory_fields = {
+ 'location_id' : {
+ 'string':'Location',
+ 'type':'many2one',
+ 'relation':'stock.location',
+ 'required':True
+ },
+ 'recursive' : {'string':'Include all childs for the location', 'type':'boolean'}
+}
+
+
+
+def _fill_inventory(self, cr, uid, data, context):
+ pool = pooler.get_pool(cr.dbname)
+ inventory_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line')
+ location_obj = pooler.get_pool(cr.dbname).get('stock.location')
+ res={}
+ res_location={}
+ if data['form']['recursive'] :
+ location_ids = location_obj.search(cr, uid, [('location_id', 'child_of', [data['form']['location_id']])])
+ for location in location_ids :
+ res=location_obj._product_get(cr, uid, location)
+ res_location[location]=res
+ else:
+ res=location_obj._product_get(cr, uid, data['form']['location_id'])
+ res_location[data['form']['location_id']]=res
+
+ product_ids=[]
+ for location in res_location.keys():
+ res=res_location[location]
+ for product_id in res.keys():
+ #product_ids.append(product_id)
+ prod = pool.get('product.product').browse(cr, uid, [product_id])[0]
+ uom = prod.uom_id.id
+ amount=pool.get('stock.location')._product_get(cr, uid, location, [product_id], {'uom': uom})[product_id]
+
+ if(amount):
+ line_ids=inventory_line_obj.search(cr,uid,[('inventory_id','=',data['id']),('location_id','=',location),('product_id','=',product_id),('product_uom','=',uom),('product_qty','=',amount)])
+ if not len(line_ids):
+ inventory_line={'inventory_id':data['id'],'location_id':location,'product_id':product_id,'product_uom':uom,'product_qty':amount}
+ inventory_line_obj.create(cr, uid, inventory_line)
+ product_ids.append(product_id)
+
+ if(len(product_ids)==0):
+ raise wizard.except_wizard('Message ! ','No product in this location.')
+ return {}
+
+
+
+class fill_inventory(wizard.interface):
+ states = {
+ 'init' : {
+ 'actions' : [],
+ 'result' : {'type' : 'form',
+ 'arch' : inventory_form,
+ 'fields' : inventory_fields,
+ 'state' : [('end', 'Cancel'),('fill_inventory', 'Fill Inventory') ]}
+ },
+ 'fill_inventory' : {
+ 'actions' : [],
+ 'result' : {'type' : 'action', 'action': _fill_inventory, 'state' : 'end'}
+ },
+ }
+fill_inventory("stock.fill_inventory")
+
+
+
diff --git a/addons/stock/wizard/wizard_move_by_location.py b/addons/stock/wizard/wizard_move_by_location.py
new file mode 100755
index 00000000000..3c1d025e721
--- /dev/null
+++ b/addons/stock/wizard/wizard_move_by_location.py
@@ -0,0 +1,61 @@
+# -*- encoding: utf-8 -*-
+import wizard
+import pooler
+import time
+
+def _action_open_window(self, cr, uid, data, context):
+ pool = pooler.get_pool(cr.dbname)
+ mod_obj = pool.get('ir.model.data')
+ act_obj = pool.get('ir.actions.act_window')
+
+ result = mod_obj._get_id(cr, uid, 'stock', 'action_move_form2')
+ id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
+ result = act_obj.read(cr, uid, [id])[0]
+ location_id = data['ids'][0]
+
+ domain = []
+# domain += [ '|' ,('location_id', '=', location_id) , ('location_dest_id', '=', location_id)]
+ if data['form']['from']:
+ domain += [('date_planned', '>=', data['form']['from'])]
+
+ if data['form']['to']:
+ domain += [('date_planned', '<=', data['form']['to'])]
+ result['domain'] = str(domain)
+# result['context'] = str({'location_id': location_id })
+ return result
+
+
+class move_by_location(wizard.interface):
+
+ form1 = '''
+ '''
+
+ form1_fields = {
+ 'from': {
+ 'string': 'From',
+ 'type': 'date',
+ },
+ 'to': {
+ 'string': 'To',
+ 'type': 'date',
+# 'default': lambda *a: time.strftime("%Y-%m-%d"),
+ },
+ }
+
+ states = {
+ 'init': {
+ 'actions': [],
+ 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [ ('open', 'Open Moves'),('end', 'Cancel')]}
+ },
+ 'open': {
+ 'actions': [],
+ 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
+ }
+ }
+
+move_by_location('stock.location.moves')
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/stock_location/stock.py b/addons/stock_location/stock.py
index 926b1d95e10..8c3626f9de8 100644
--- a/addons/stock_location/stock.py
+++ b/addons/stock_location/stock.py
@@ -73,5 +73,5 @@ class stock_location(osv.osv):
for path in product.path_ids:
if path.location_from_id.id == location.id:
return path.location_dest_id, path.auto, path.delay
- return super(stock_location, self).chained_location_get(cr, uid, location, partner, product, contex)
+ return super(stock_location, self).chained_location_get(cr, uid, location, partner, product, context)
stock_location()
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..a8b276aaa7c
--- /dev/null
+++ b/addons/warning/warning.py
@@ -0,0 +1,191 @@
+# -*- 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 = {}
+ title=False
+ message=False
+ partner = self.pool.get('res.partner').browse(cr, uid, part)
+ if partner.sale_warn:
+ title= "Message",
+ message=partner.sale_warn_msg
+
+ result = super(sale_order, self).onchange_partner_id(cr, uid, ids, part)['value']
+ if result.get('warning',False):
+ warning['title']=title and title+' & '+result['warning']['title'] or result['warning']['title']
+ warning['message']=message and message +' '+result['warning']['message'] or result['warning']['message']
+ 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)
+ title=False
+ message=False
+ if product_info.sale_line_warn:
+ 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']
+ if result.get('warning',False):
+ warning['title']=title and title+' & '+result['warning']['title'] or result['warning']['title']
+ warning['message']=message and message +' '+result['warning']['message'] or result['warning']['message']
+ 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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+