Mayur Maheshwari(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-addons_issue10_warning-mma into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-addons_issue10_warning-mma/+merge/124911

Hello,

  I have done the following changes:

1] I define a warning for the purchase (a warning and a blocking message) , 
When I create a PO and I select the product but I do not have any warning 
message

2] no warning message/blocking message pop up for incoming shipment and 
delivery order when I select a partner 


Thanks
Mayur
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-addons_issue10_warning-mma/+merge/124911
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-addons_issue10_warning-mma.
=== modified file 'warning/warning.py'
--- warning/warning.py	2012-03-30 09:08:37 +0000
+++ warning/warning.py	2012-09-18 12:55:16 +0000
@@ -174,6 +174,64 @@
 
 stock_picking()
 
+# FIXME:(class stock_picking_in and stock_picking_out) this is a temporary workaround because of a framework bug (ref: lp:996816). 
+# It should be removed as soon as the bug is fixed
+class stock_picking_in(osv.osv):
+    _inherit = 'stock.picking.in'
+
+    def onchange_partner_in(self, cr, uid, context, partner_id=None):
+        if not partner_id:
+            return {}
+        partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
+        warning = {}
+        title = False
+        message = False
+        if partner.picking_warn != 'no-message':
+            if partner.picking_warn == 'block':
+                raise osv.except_osv(_('Alert for %s !') % (partner.name), partner.picking_warn_msg)
+            title = _("Warning for %s") % partner.name
+            message = partner.picking_warn_msg
+            warning = {
+                'title': title,
+                'message': message
+            }
+        result =  super(stock_picking_in, self).onchange_partner_in(cr, uid, context, partner_id)
+        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.get('value',{}), 'warning':warning}
+
+stock_picking_in()
+
+class stock_picking_out(osv.osv):
+    _inherit = 'stock.picking.out'
+
+    def onchange_partner_in(self, cr, uid, context, partner_id=None):
+        if not partner_id:
+            return {}
+        partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
+        warning = {}
+        title = False
+        message = False
+        if partner.picking_warn != 'no-message':
+            if partner.picking_warn == 'block':
+                raise osv.except_osv(_('Alert for %s !') % (partner.name), partner.picking_warn_msg)
+            title = _("Warning for %s") % partner.name
+            message = partner.picking_warn_msg
+            warning = {
+                'title': title,
+                'message': message
+            }
+        result =  super(stock_picking_out, self).onchange_partner_in(cr, uid, context, partner_id)
+        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.get('value',{}), 'warning':warning}
+
+stock_picking_out()
+
 class product_product(osv.osv):
     _inherit = 'product.product'
     _columns = {
@@ -228,8 +286,8 @@
 
 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, fiscal_position=False, date_planned=False,
+    def onchange_product_id(self,cr, uid, ids, pricelist, product, qty, uom,
+            partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
             name=False, price_unit=False, notes=False, context=None):
         warning = {}
         if not product:
@@ -247,8 +305,8 @@
             warning['title'] = title
             warning['message'] = message
 
-        result =  super(purchase_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty, uom,
-            partner_id, date_order, fiscal_position)
+        result =  super(purchase_order_line, self).onchange_product_id(cr, uid, ids, pricelist, product, qty, uom,
+            partner_id, date_order, fiscal_position_id)
 
         if result.get('warning',False):
             warning['title'] = title and title +' & '+result['warning']['title'] or result['warning']['title']

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to