Rifakat (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/6.1-opw-576019-rha into
lp:openobject-addons/6.1.
Requested reviews:
Naresh(OpenERP) (nch-openerp)
Priyesh (OpenERP) (pso-openerp)
Olivier Dony (OpenERP) (odo-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-576019-rha/+merge/111556
Hello,
Product UoM is not properly set when doing on_change on product in Sale line
and Purchase line
while Product belong to the very same category of already filled UoM in line
form.
Steps to produce:
1. When we open sale/purchase line form there will be default value 'PCE' for
UoM
2. Do on_change for any product whose UoM category is Unit.(say UoM=10PCE)
3. 10PCE should be filled for UoM on on_change but it remains 'PCE'
Kindly review this fix,
Rifakat Haradwala
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-576019-rha/+merge/111556
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/6.1-opw-576019-rha.
=== modified file 'purchase/purchase.py'
--- purchase/purchase.py 2012-02-16 12:34:08 +0000
+++ purchase/purchase.py 2012-06-22 07:43:23 +0000
@@ -705,9 +705,10 @@
"""
if not uom_id:
return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or'', 'product_uom' : uom_id or False}}
+ context.update(uom_change=True)
return self.onchange_product_id(cr, uid, ids, pricelist_id, product_id, qty, uom_id,
- partner_id, date_order=date_order, fiscal_position_id=fiscal_position_id, date_planned=date_planned,
- name=name, price_unit=price_unit, notes=notes, context=context)
+ partner_id, date_order=date_order, fiscal_position_id=fiscal_position_id, date_planned=date_planned,
+ name=name, price_unit=price_unit, notes=notes, context=context)
def _get_date_planned(self, cr, uid, supplier_info, date_order_str, context=None):
"""Return the datetime value to use as Schedule Date (``date_planned``) for
@@ -764,11 +765,13 @@
product_uom_po_id = product.uom_po_id.id
if not uom_id:
uom_id = product_uom_po_id
-
+
+ if not context.get('uom_change'):
+ uom_id = product.uom_id.id
if product.uom_id.category_id.id != product_uom.browse(cr, uid, uom_id, context=context).category_id.id:
res['warning'] = {'title': _('Warning'), 'message': _('Selected UOM does not belong to the same category as the product UOM')}
uom_id = product_uom_po_id
-
+
res['value'].update({'product_uom': uom_id})
# - determine product_qty and date_planned based on seller info
=== modified file 'sale/sale.py'
--- sale/sale.py 2012-02-16 16:52:53 +0000
+++ sale/sale.py 2012-06-22 07:43:23 +0000
@@ -1197,7 +1197,7 @@
product_uom_obj = self.pool.get('product.uom')
partner_obj = self.pool.get('res.partner')
product_obj = self.pool.get('product.product')
- context = {'lang': lang, 'partner_id': partner_id}
+ context.update(lang=lang, partner_id=partner_id)
if partner_id:
lang = partner_obj.browse(cr, uid, partner_id).lang
context_partner = {'lang': lang, 'partner_id': partner_id}
@@ -1213,12 +1213,10 @@
result = res.get('value', {})
warning_msgs = res.get('warning') and res['warning']['message'] or ''
product_obj = product_obj.browse(cr, uid, product, context=context)
-
+
uom2 = False
- if uom:
+ if uom and context.get('uom_change'):
uom2 = product_uom_obj.browse(cr, uid, uom)
- if product_obj.uom_id.category_id.id != uom2.category_id.id:
- uom = False
if uos:
if product_obj.uos_id:
uos2 = product_uom_obj.browse(cr, uid, uos)
@@ -1252,6 +1250,10 @@
[('category_id', '=', product_obj.uom_id.category_id.id)],
'product_uos':
[('category_id', '=', uos_category_id)]}
+
+ if not context.get('uom_change'):
+ res['value'].update(product_uom=product_obj.uom_id.id)
+ uom = product_obj.uom_id.id
elif uos and not uom: # only happens if uom is False
result['product_uom'] = product_obj.uom_id and product_obj.uom_id.id
@@ -1309,6 +1311,7 @@
lang=False, update_tax=True, date_order=False, context=None):
context = context or {}
lang = lang or ('lang' in context and context['lang'])
+ context.update(uom_change=True)
res = self.product_id_change(cursor, user, ids, pricelist, product,
qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name,
partner_id=partner_id, lang=lang, update_tax=update_tax,
_______________________________________________
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