Task-ID:506 Improve the onchange on product_id

bzr revid: sbh@tinyerp.com-20100505124859-ir4qt1lbfjefe0bf
This commit is contained in:
sbh (Open ERP) 2010-05-05 18:18:59 +05:30
parent e741cb9de4
commit 894efa6564
4 changed files with 11 additions and 10 deletions

View File

@ -36,7 +36,7 @@
<data>
<record id="res_groups_posuserposline0" model="res.groups">
<field eval="[(6,0,[ref('point_of_sale.menu_action_pos_order_line'),ref('point_of_sale.menu_action_pos_order_line_day')])]" name="menu_access"/>
<field eval="[(6,0,[ref('ir_rule_0')])]" name="groups"/>
<field eval="[(6,0,[ref('ir_rule_0')])]" name="rule_groups"/>
<field eval="[(6,0,[ref('res_users_shopuser0'),ref('res_users_shopuser1')])]" name="users"/>
<field eval="&quot;&quot;&quot;POS_user_pos_line&quot;&quot;&quot;" name="name"/>
</record>

View File

@ -86,7 +86,7 @@ class purchase_requisition_line(osv.osv):
'requisition_id' : fields.many2one('purchase.requisition','Purchase Requisition', ondelete='cascade')
}
def onchange_product_id(self, cr, uid, ids, product_id, context={}):
def onchange_product_id(self, cr, uid, ids, product_id,product_uom_id, context={}):
""" Changes UoM and name if product_id changes.
@param name: Name of the field
@ -94,13 +94,14 @@ class purchase_requisition_line(osv.osv):
@return: Dictionary of changed values
"""
value = {}
if product_id:
prod = self.pool.get('product.product').browse(cr, uid, [product_id])[0]
value = {'product_uom_id': prod.uom_id.id}
if product_uom_id != prod.uom_id.id:
value = {'product_uom_id': prod.uom_id.id}
return {'value': value}
_defaults = {
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}

View File

@ -46,14 +46,14 @@
<page string="Products">
<field name="line_ids" colspan="4" nolabel="1">
<tree string="Products" editable="bottom">
<field name="product_id" on_change="onchange_product_id(product_id)"/>
<field name="product_id" on_change="onchange_product_id(product_id,product_uom_id)"/>
<field name="product_qty"/>
<field name="product_uom_id"/>
</tree>
<form string="Products" editable="bottom">
<field name="product_id"/>
<field name="product_id" />
<field name="product_qty"/>
<field name="product_uom_id"/>
<field name="product_uom_id" />
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
</form>

View File

@ -111,11 +111,11 @@ class purchase_requisition_partner(osv.osv_memory):
})
list_line.append(purchase_order_line)
purchase_id = order_obj.create(cr, uid, {
'origin': tender.name,
'origin': tender.purchase_ids and tender.purchase_ids[0].origin or tender.name,
'partner_id': partner_id,
'partner_address_id': address_id,
'pricelist_id': pricelist_id,
'location_id': line.product_id.product_tmpl_id.property_stock_production.id,
'location_id': tender.purchase_ids and tender.purchase_ids[0].location_id.id or line.product_id.product_tmpl_id.property_stock_production.id,
'company_id': tender.company_id.id,
'fiscal_position': partner.property_account_position and partner.property_account_position.id or False,
'requisition_id':tender.id,