[IMP] BOARD,STOCK,SURVEY :Improvement in OSV wiz ,Realated Read method

bzr revid: aag@tinyerp.co.in-20110215105509-pjve7asi0r63knec
This commit is contained in:
aag (OpenERP) 2011-02-15 16:25:09 +05:30
parent c1cd88b1d9
commit 63f66fdec1
11 changed files with 19 additions and 83 deletions

View File

@ -70,10 +70,10 @@ class board_menu_create(osv.osv_memory):
}) })
obj_menu = self.pool.get('ir.ui.menu') obj_menu = self.pool.get('ir.ui.menu')
#start Loop #start Loop
for data in self.read(cr, uid, ids): for data in self.browse(cr, uid, ids, context=context):
obj_menu.create(cr, uid, { obj_menu.create(cr, uid, {
'name': data.get('menu_name'), 'name': data.menu_name,
'parent_id': data.get('menu_parent_id'), 'parent_id': data.menu_parent_id.id,
'icon': 'STOCK_SELECT_COLOR', 'icon': 'STOCK_SELECT_COLOR',
'action': 'ir.actions.act_window,' + str(action_id) 'action': 'ir.actions.act_window,' + str(action_id)
}, context=context) }, context=context)

View File

@ -1114,7 +1114,6 @@ msgstr ""
#: view:stock.invoice.onshipping:0 #: view:stock.invoice.onshipping:0
#: view:stock.location.product:0 #: view:stock.location.product:0
#: view:stock.move:0 #: view:stock.move:0
#: view:stock.move.track:0
#: view:stock.picking:0 #: view:stock.picking:0
#: view:stock.split.into:0 #: view:stock.split.into:0
msgid "_Cancel" msgid "_Cancel"
@ -1693,7 +1692,6 @@ msgid "Search Inventory"
msgstr "" msgstr ""
#. module: stock #. module: stock
#: field:stock.move.track,quantity:0
msgid "Quantity per lot" msgid "Quantity per lot"
msgstr "" msgstr ""
@ -1920,7 +1918,6 @@ msgstr ""
#. module: stock #. module: stock
#: model:ir.actions.act_window,name:stock.track_line_old #: model:ir.actions.act_window,name:stock.track_line_old
#: view:stock.move.track:0
msgid "Tracking a move" msgid "Tracking a move"
msgstr "" msgstr ""
@ -2461,7 +2458,6 @@ msgid "If checked, products contained in child locations of selected location wi
msgstr "" msgstr ""
#. module: stock #. module: stock
#: field:stock.move.track,tracking_prefix:0
msgid "Tracking prefix" msgid "Tracking prefix"
msgstr "" msgstr ""
@ -2901,7 +2897,6 @@ msgstr ""
#: view:stock.move.consume:0 #: view:stock.move.consume:0
#: view:stock.move.scrap:0 #: view:stock.move.scrap:0
#: view:stock.move.split:0 #: view:stock.move.split:0
#: view:stock.move.track:0
#: view:stock.split.into:0 #: view:stock.split.into:0
msgid "Ok" msgid "Ok"
msgstr "" msgstr ""

View File

@ -21,35 +21,6 @@
from osv import fields, osv from osv import fields, osv
class stock_move_track(osv.osv_memory):
_name = "stock.move.track"
_description = "Track moves"
_columns = {
'tracking_prefix': fields.char('Tracking prefix', size=64),
'quantity': fields.float("Quantity per lot")
}
_defaults = {
'quantity': lambda *x: 1
}
def track_lines(self, cr, uid, ids, context=None):
""" To track stock moves lines
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: An ID or list of IDs if we want more than one
@param context: A standard dictionary
@return:
"""
datas = self.read(cr, uid, ids)[0]
move_obj = self.pool.get('stock.move')
move_obj._track_lines(cr, uid, context['active_id'], datas, context=context)
return {'type': 'ir.actions.act_window_close'}
stock_move_track()
class stock_move_consume(osv.osv_memory): class stock_move_consume(osv.osv_memory):
_name = "stock.move.consume" _name = "stock.move.consume"
_description = "Consume Products" _description = "Consume Products"

View File

@ -2,34 +2,6 @@
<openerp> <openerp>
<data> <data>
<record id="view_stock_move_track_wizard" model="ir.ui.view">
<field name="name">Tracking a move</field>
<field name="model">stock.move.track</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Tracking a move">
<field name="tracking_prefix" colspan="4"/>
<field name="quantity" colspan="4"/>
<newline/>
<separator string="" colspan="4" />
<button icon='gtk-cancel' special="cancel"
string="_Cancel" />
<button name="track_lines" string="Ok"
type="object" icon="gtk-ok" />
</form>
</field>
</record>
<record id="track_line_old" model="ir.actions.act_window">
<field name="name">Tracking a move</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.move.track</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<!-- Consume, scrap move --> <!-- Consume, scrap move -->
<record id="view_stock_move_consume_wizard" model="ir.ui.view"> <record id="view_stock_move_consume_wizard" model="ir.ui.view">

View File

@ -107,7 +107,7 @@ class stock_split_move_line(osv.osv_memory):
record_id = context and context.get('active_id', False) or False record_id = context and context.get('active_id', False) or False
pick_obj = self.pool.get('stock.picking') pick_obj = self.pool.get('stock.picking')
pick = pick_obj.browse(cr, uid, record_id, context=context) pick = pick_obj.browse(cr, uid, record_id, context=context)
data = self.read(cr, uid, ids[0]) data = self.read(cr, uid, ids[0], context=context)
for move in pick.move_lines: for move in pick.move_lines:
quantity = data['move%s' % move.id] quantity = data['move%s' % move.id]
if 0 < quantity < move.product_qty: if 0 < quantity < move.product_qty:

View File

@ -61,14 +61,13 @@ class survey_browse_answer(osv.osv_memory):
@return : Dictionary value for Open the browse answer wizard. @return : Dictionary value for Open the browse answer wizard.
""" """
if context is None: context = {} if context is None: context = {}
record = self.read(cr, uid, ids, []) sur_response_obj = self.pool.get('survey.response')
record = record and record[0] or {} for record in self.browse(cr, uid, ids,context=context):
if record['response_id']: if record.response_id.id:
res_id = [(record['response_id'])] res_id = record.response_id.id
else: else:
sur_response_obj = self.pool.get('survey.response') res_id = sur_response_obj.search(cr, uid, [('survey_id', '=',record.survey_id)])[0]
res_id = sur_response_obj.search(cr, uid, [('survey_id', '=',int(record['survey_id']))]) context.update({'active' : True,'survey_id' : record.survey_id, 'response_id' : [res_id], 'response_no' : 0})
context.update({'active' : True,'survey_id' : record['survey_id'], 'response_id' : res_id, 'response_no' : 0})
search_obj = self.pool.get('ir.ui.view') search_obj = self.pool.get('ir.ui.view')
search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')]) search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')])
return { return {

View File

@ -55,10 +55,9 @@ class survey_print(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return : Dictionary value for print survey form. @return : Dictionary value for print survey form.
""" """
datas = {'ids' : self.read(cr, uid, ids, ['survey_ids'], context=context)[0]['survey_ids']}
datas = {'ids' : self.read(cr, uid, ids, [], context)[0]['survey_ids']}
res = self.read(cr, uid, ids, ['survey_title', 'orientation', 'paper_size',\ res = self.read(cr, uid, ids, ['survey_title', 'orientation', 'paper_size',\
'page_number', 'without_pagebreak'], context) 'page_number', 'without_pagebreak'], context=context)
res = res and res[0] or {} res = res and res[0] or {}
datas['form'] = res datas['form'] = res
datas['model'] = 'survey.print' datas['model'] = 'survey.print'

View File

@ -59,7 +59,7 @@ class survey_print_answer(osv.osv_memory):
context = {} context = {}
datas = {'ids': context.get('active_ids', [])} datas = {'ids': context.get('active_ids', [])}
res = self.read(cr, uid, ids, ['response_ids', 'orientation', 'paper_size',\ res = self.read(cr, uid, ids, ['response_ids', 'orientation', 'paper_size',\
'page_number', 'without_pagebreak'], context) 'page_number', 'without_pagebreak'], context=context)
res = res and res[0] or {} res = res and res[0] or {}
datas['form'] = res datas['form'] = res
datas['model'] = 'survey.print.answer' datas['model'] = 'survey.print.answer'

View File

@ -44,7 +44,7 @@ class survey_print_statistics(osv.osv_memory):
if context is None: if context is None:
context = {} context = {}
datas = {'ids': context.get('active_ids', [])} datas = {'ids': context.get('active_ids', [])}
res = self.read(cr, uid, ids, ['survey_ids'], context) res = self.read(cr, uid, ids, ['survey_ids'], context=context)
res = res and res[0] or {} res = res and res[0] or {}
datas['form'] = res datas['form'] = res
datas['model'] = 'survey.print.statistics' datas['model'] = 'survey.print.statistics'

View File

@ -122,7 +122,7 @@ class survey_name_wiz(osv.osv_memory):
search_obj = self.pool.get('ir.ui.view') search_obj = self.pool.get('ir.ui.view')
if context is None: context = {} if context is None: context = {}
sur_id = self.read(cr, uid, ids, [])[0] sur_id = self.read(cr, uid, ids, ['survey_id'], context=context)[0]
survey_id = sur_id['survey_id'] survey_id = sur_id['survey_id']
context.update({'survey_id': survey_id, 'sur_name_id': sur_id['id']}) context.update({'survey_id': survey_id, 'sur_name_id': sur_id['id']})
cr.execute('select count(id) from survey_history where user_id=%s\ cr.execute('select count(id) from survey_history where user_id=%s\
@ -133,8 +133,8 @@ class survey_name_wiz(osv.osv_memory):
if user_limit and res >= user_limit: if user_limit and res >= user_limit:
raise osv.except_osv(_('Warning !'),_("You can not give response for this survey more than %s times") % (user_limit)) raise osv.except_osv(_('Warning !'),_("You can not give response for this survey more than %s times") % (user_limit))
sur_rec = survey_obj.read(cr,uid,self.read(cr,uid,ids)[0]['survey_id']) sur_rec = survey_obj.browse(cr,uid,ids,context=context)[0]
if sur_rec['max_response_limit'] and sur_rec['max_response_limit'] <= sur_rec['tot_start_survey']: if sur_rec.max_response_limit and sur_rec.max_response_limit <= sur_rec.tot_start_survey:
raise osv.except_osv(_('Warning !'),_("You can not give more response. Please contact the author of this survey for further assistance.")) raise osv.except_osv(_('Warning !'),_("You can not give more response. Please contact the author of this survey for further assistance."))
search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')]) search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')])

View File

@ -96,7 +96,7 @@ class survey_send_invitation(osv.osv_memory):
def action_send(self, cr, uid, ids, context=None): def action_send(self, cr, uid, ids, context=None):
if context is None: if context is None:
context = {} context = {}
record = self.read(cr, uid, ids, []) record = self.read(cr, uid, ids, [],context=context)
survey_ids = context.get('active_ids', []) survey_ids = context.get('active_ids', [])
record = record and record[0] record = record and record[0]
partner_ids = record['partner_ids'] partner_ids = record['partner_ids']