[MERGE] lp:831543 about onchange_operation_type() that contained hardcoded names of location in mrp_repair module

bzr revid: qdp-launchpad@openerp.com-20111026095653-nvk5gvtr14eihxwb
This commit is contained in:
Quentin (OpenERP) 2011-10-26 11:56:53 +02:00
commit 5f43160a61
3 changed files with 26 additions and 21 deletions

View File

@ -665,7 +665,7 @@ class mrp_repair_line(osv.osv, ProductChangeMixin):
'product_uom_qty': lambda *a: 1,
}
def onchange_operation_type(self, cr, uid, ids, type, guarantee_limit):
def onchange_operation_type(self, cr, uid, ids, type, guarantee_limit, company_id=False, context=None):
""" On change of operation type it sets source location, destination location
and to invoice field.
@param product: Changed operation type.
@ -676,27 +676,32 @@ class mrp_repair_line(osv.osv, ProductChangeMixin):
return {'value': {
'location_id': False,
'location_dest_id': False
}
}
}}
warehouse_obj = self.pool.get('stock.warehouse')
location_id = self.pool.get('stock.location').search(cr, uid, [('usage','=','production')], context=context)
location_id = location_id and location_id[0] or False
if type == 'add':
# TOCHECK: Find stock location for user's company warehouse or
# repair order's company's warehouse (company_id field is added in fix of lp:831583)
args = company_id and [('company_id', '=', company_id)] or []
warehouse_ids = warehouse_obj.search(cr, uid, args, context=context)
stock_id = False
if warehouse_ids:
stock_id = warehouse_obj.browse(cr, uid, warehouse_ids[0], context=context).lot_stock_id.id
to_invoice = (guarantee_limit and datetime.strptime(guarantee_limit, '%Y-%m-%d') < datetime.now())
product_id = self.pool.get('stock.location').search(cr, uid, [('name','=','Production')])[0]
if type != 'add':
return {'value': {
'to_invoice': False,
'location_id': product_id,
'location_dest_id': False
}
}
'to_invoice': to_invoice,
'location_id': stock_id,
'location_dest_id': location_id
}}
stock_id = self.pool.get('stock.location').search(cr, uid, [('name','=','Stock')])[0]
to_invoice = (guarantee_limit and
datetime.strptime(guarantee_limit, '%Y-%m-%d') < datetime.now())
return {'value': {
'to_invoice': to_invoice,
'location_id': stock_id,
'location_dest_id': product_id
}
}
'to_invoice': False,
'location_id': location_id,
'location_dest_id': False
}}
mrp_repair_line()

View File

@ -59,7 +59,7 @@
<field name="location_id"/>
<field name="location_dest_id"/>
<newline/>
<field name="type" on_change="onchange_operation_type(type,parent.guarantee_limit)"/>
<field name="type" on_change="onchange_operation_type(type,parent.guarantee_limit,parent.company_id,context)"/>
<group colspan="2">
<field name="to_invoice"/>
<field name="invoiced"/>
@ -77,7 +77,7 @@
</notebook>
</form>
<tree string="Operations" editable="bottom">
<field name="type" on_change="onchange_operation_type(type,parent.guarantee_limit)"/>
<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='name'/>
<field name="prodlot_id" />

View File

@ -61,7 +61,7 @@
On change of operation type it sets source location, destination location and to invoice field
-
!python {model: mrp.repair.line}: |
self.onchange_operation_type(cr, uid, [ref('mrp_repair_rma0')], type, False)
self.onchange_operation_type(cr, uid, [ref('mrp_repair_rma0')], type, False, ref('base.main_company'), {})
-
On change of partner sets the values of partner address, partner invoice address and pricelist.
-