diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index 2015b11d7c2550b1da31df81c77dc250a0898e6b..d8c8925b24f698e9f948b03dcc13f0ba0ae38ba2 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -495,7 +495,7 @@ class mrp_repair(osv.osv): class ProductChangeMixin(object): def product_id_change(self, cr, uid, ids, pricelist, product, uom=False, - product_uom_qty=0, partner_id=False, guarantee_limit=False): + product_uom_qty=0, partner_id=False, guarantee_limit=False, context=None): """ On change of product it sets product quantity, tax account, name, uom of product, unit price and price subtotal. @param pricelist: Pricelist of current record. @@ -508,16 +508,18 @@ class ProductChangeMixin(object): """ result = {} warning = {} + ctx = context and context.copy() or {} + ctx['uom'] = uom if not product_uom_qty: product_uom_qty = 1 result['product_uom_qty'] = product_uom_qty if product: - product_obj = self.pool.get('product.product').browse(cr, uid, product) + product_obj = self.pool.get('product.product').browse(cr, uid, product, context=ctx) if partner_id: partner = self.pool.get('res.partner').browse(cr, uid, partner_id) - result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, partner.property_account_position, product_obj.taxes_id) + result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, partner.property_account_position, product_obj.taxes_id, context=ctx) result['name'] = product_obj.display_name result['product_uom'] = product_obj.uom_id and product_obj.uom_id.id or False @@ -530,7 +532,7 @@ class ProductChangeMixin(object): } else: price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist], - product, product_uom_qty, partner_id, {'uom': uom})[pricelist] + product, product_uom_qty, partner_id, context=ctx)[pricelist] if price is False: warning = { diff --git a/addons/mrp_repair/mrp_repair_view.xml b/addons/mrp_repair/mrp_repair_view.xml index e11acdb6b567530d270397d88843d5bcea372b60..2f160cf1aef7514e5e59a0d7a7a5f663fd071d09 100644 --- a/addons/mrp_repair/mrp_repair_view.xml +++ b/addons/mrp_repair/mrp_repair_view.xml @@ -68,7 +68,7 @@ <page string="Repair Line"> <group col="4"> <field name="name"/> - <field name="product_id" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id)"/> + <field name="product_id" on_change="product_id_change(parent.pricelist_id, product_id, product_uom, product_uom_qty, parent.partner_id, False, context)"/> <label for="product_uom_qty"/> <div> <field name="product_uom_qty" class="oe_inline"/> @@ -94,7 +94,7 @@ </form> <tree string="Operations" editable="bottom"> <field name="type" on_change="onchange_operation_type(type,parent.guarantee_limit,parent.company_id,context)"/> - <field name="product_id" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id)"/> + <field name="product_id" on_change="product_id_change(parent.pricelist_id, product_id, product_uom, product_uom_qty, parent.partner_id, False, context)"/> <field name='name'/> <field name="lot_id" domain="[('product_id', '=', product_id)]" context="{'default_product_id': product_id}" groups="stock.group_production_lot"/> <field name="location_id" groups="stock.group_locations"/> @@ -139,7 +139,7 @@ <group string="Product Information"> <group> <field name="to_invoice"/> - <field name="product_id" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id,parent.guarantee_limit)"/> + <field name="product_id" on_change="product_id_change(parent.pricelist_id, product_id, product_uom, product_uom_qty, parent.partner_id, parent.guarantee_limit, context)"/> <label for="product_uom_qty"/> <div> <field name="product_uom_qty" string="Quantity" class="oe_inline"/> @@ -162,7 +162,7 @@ </group> </form> <tree string="Fees" editable="bottom"> - <field name="product_id" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id,parent.guarantee_limit)"/> + <field name="product_id" on_change="product_id_change(parent.pricelist_id, product_id, product_uom, product_uom_qty, parent.partner_id,parent.guarantee_limit, context)"/> <field name='name'/> <field name="product_uom_qty" string="Quantity"/> <field name="product_uom" string="Unit of Measure" groups="product.group_uom"/>