merge from parent

bzr revid: nch@tinyerp.com-20090504060948-wxcljbifb4fp7afo
This commit is contained in:
Naresh Choksy
2009-05-04 11:39:48 +05:30
7 changed files with 85 additions and 45 deletions
@@ -47,6 +47,32 @@ from tools.translate import _
# return super(ir_model_fields, self).search(cr, uid, args, offset, limit, order, context)
#ir_model_fields()
class ir_model(osv.osv):
_inherit = 'ir.model'
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
res_model_ids = super(ir_model,self).search(cr, uid, args, offset, limit, order, context=context, count=count)
try:
if 'model_ids' in context and context['model_ids'][0][2]:
model_ids = context['model_ids'][0][2]
result = []
name_list = []
if model_ids:
obj = self.read(cr, uid, model_ids,['model'])
for name in obj:
name_list.append(name['model'])
cr.execute("SELECT model_id, relation FROM ir_model_fields WHERE relation in (%s)" % (','.join(map(lambda x: "'"+str(x)+"'",name_list))))
for r in cr.fetchall():
result.append(r[0])
return result
return res_model_ids
except Exception,e:
pass
ir_model()
class report_creator(osv.osv):
_name = "base_report_creator.report"
_description = "Report"
@@ -354,8 +380,8 @@ class report_creator(osv.osv):
_constraints = [
(_function_field, 'You can not display field which are not stored in Database.', ['field_ids']),
(_aggregation_error, 'You can apply agregate function to the non calculated field.', ['field_ids']),
(_calander_view_error, "You must have to give calander view's color,start date and delay.", ['field_ids']),
(_aggregation_error, 'You can apply aggregate function to the non calculated field.', ['field_ids']),
(_calander_view_error, "You must have to give calendar view's color,start date and delay.", ['field_ids']),
]
report_creator()
@@ -38,7 +38,7 @@
<field name="active" select="2"/>
<notebook colspan="4">
<page string="General Configuration">
<field name="model_ids" colspan="4"/>
<field name="model_ids" colspan="4" context="{'model_ids':model_ids}"/>
<separator string="State" colspan="4"/>
<field name="state"/>
<button string="Create Menu" name="%(wizard_menu_create)d" type="action" colspan="2"/>
@@ -72,7 +72,7 @@ def set_field_operator(self,field_name,field_type,search_operator,search_value):
field_search[1]='in'
field_search[2] = "("+','.join([str(x) for x in search_value])+")"
elif field_type in char_type or field_type in date_type:
field_search[2] = "'"+field_search[2]+"'"
field_search[2] = field_search[2] and "'"+field_search[2]+"'" or False
elif search_operator == '<>':
if field_type=='many2one':
field_search[1]='not in'
@@ -123,18 +123,17 @@ def _set_filter_value(self, cr, uid, data, context):
table_name = model_pool._table
model_name = model_pool._description
if field_type == 'boolean' and value_data == 1:
value_data = 'true'
else:
value_data = 'false'
if field_type:
if field_type == 'boolean':
if value_data == 1:
value_data = 'true'
else:
value_data = 'false'
if field_type == 'many2many' and value_data and len(value_data):
fields_list = set_field_operator(self,table_name+"."+field_data['name'],field_data['ttype'],form_data['operator'],value_data[0][2])
else:
fields_list = set_field_operator(self,table_name+"."+field_data['name'],field_data['ttype'],form_data['operator'],value_data)
if fields_list and value_data:
if fields_list:
create_dict = {
'name':model_name + "/" +field_data['field_description'] +" "+ mapping_fields[form_data['operator']] + " " + str(fields_list[2]) + " ",
'expression':' '.join(fields_list),
+35 -28
View File
@@ -111,43 +111,51 @@ class wizard_base_setup(wizard.interface):
return res
def _get_company(self, cr, uid, data, context):
pool=pooler.get_pool(cr.dbname)
company_obj=pool.get('res.company')
pool = pooler.get_pool(cr.dbname)
company_obj = pool.get('res.company')
ids=company_obj.search(cr, uid, [])
if not ids:
return {}
company=company_obj.browse(cr, uid, ids)[0]
self.fields['name']['default']=company.name
self.fields['currency']['default']=company.currency_id.id
serv_pro_id = pooler.get_pool(cr.dbname).get('ir.module.module').search(cr, uid, [('name','=','profile_service')]) or False
company = company_obj.browse(cr, uid, ids)[0]
res = {'currency': company.currency_id.id}
for field in 'name logo rml_header1 rml_footer1 rml_footer2'.split():
res[field] = company[field]
if company.partner_id.address:
address = company.partner_id.address[0]
for field in 'street street2 zip city email phone'.split():
res[field] = address[field]
for field in 'country_id state_id'.split():
if address[field]:
res[field] = address[field].id
serv_pro_id = pool.get('ir.module.module').search(cr, uid, [('name','=','profile_service')]) or False
if serv_pro_id:
return {'profile':serv_pro_id[0]}
return {}
res['profile'] = serv_pro_id[0]
return res
def _get_all(self, cr, uid, context, model):
pool = pooler.get_pool(cr.dbname)
obj = pool.get(model)
ids = obj.search(cr, uid, [])
res = [(o.id, o.name) for o in obj.browse(cr, uid, ids, context=context)]
res.append((-1, ''))
res.sort(key=lambda x: x[1])
return res
def _get_states(self, cr, uid, context):
pool=pooler.get_pool(cr.dbname)
state_obj=pool.get('res.country.state')
ids=state_obj.search(cr, uid, [])
res=[(state.id, state.name) for state in state_obj.browse(cr, uid, ids, context=context)]
res.append((-1, ''))
res.sort(lambda x,y: cmp(x[1],y[1]))
return res
return self._get_all(cr, uid, context, 'res.country.state')
def _get_countries(self, cr, uid, context):
pool=pooler.get_pool(cr.dbname)
country_obj=pool.get('res.country')
ids=country_obj.search(cr, uid, [])
res=[(country.id, country.name) for country in country_obj.browse(cr, uid, ids, context=context)]
res.sort(lambda x,y: cmp(x[1],y[1]))
return res
return self._get_all(cr, uid, context, 'res.country')
def _get_currency(self, cr, uid, context):
pool=pooler.get_pool(cr.dbname)
currency_obj=pool.get('res.currency')
ids=currency_obj.search(cr, uid, [])
res=[(currency.id, currency.name) for currency in currency_obj.browse(cr, uid, ids, context=context)]
res.sort(lambda x,y: cmp(x[1],y[1]))
return res
return self._get_all(cr, uid, context, 'res.currency')
def _update(self, cr, uid, data, context):
pool=pooler.get_pool(cr.dbname)
@@ -256,7 +264,6 @@ class wizard_base_setup(wizard.interface):
'string':'Profile',
'type':'selection',
'selection':_get_profiles,
# 'default': _get_service_profile,
'required': True,
},
+9 -1
View File
@@ -111,7 +111,15 @@ class hr_analytic_timesheet(osv.osv):
}
def on_change_account_id(self, cr, uid, ids, account_id):
return {'value':{}}
def on_change_date(self, cr, uid, ids, date):
if ids:
new_date = self.read(cr,uid,ids[0],['date'])['date']
if date != new_date:
warning = {'title':'User Alert!','message':'Changing the date will let this entry appear in the timesheet of the new date.'}
return {'value':{},'warning':warning}
return {'value':{}}
def create(self, cr, uid, vals, context={}):
try:
res = super(hr_analytic_timesheet, self).create(cr, uid, vals, context)
+3 -3
View File
@@ -8,7 +8,7 @@
<field name="arch" type="xml">
<tree editable="bottom" string="Timesheet Line">
<field name="user_id" on_change="on_change_user_id(user_id)" required="1"/>
<field name="date"/>
<field name="date" on_change="on_change_date(date)"/>
<field domain="[('type','=','normal'),('state', '&lt;&gt;', 'close')]" name="account_id"/>
<field name="name"/>
<field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)" sum="Total time"/>
@@ -25,9 +25,9 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Timesheet Lines">
<field colspan="4" name="name"/>
<field colspan="4" name="name" select="2"/>
<field name="user_id" on_change="on_change_user_id(user_id)" required="1" select="1"/>
<field name="date" select="1"/>
<field name="date" select="1" on_change="on_change_date(date)"/>
<field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)"/>
<newline/>
<field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)" required="1" domain="[('type','=','service')]"/>
@@ -369,7 +369,7 @@ class hr_timesheet_line(osv.osv):
elif (x[2] is False) and (x[1] == '<>' or x[1] == '!='):
qu1.append('(s.id IS NOT NULL)')
else:
qu1.append('(s.id %s %s)' % (x[1], '%d'))
qu1.append('(s.id %s %s)' % (x[1], '%s'))
qu2.append(x[2])
elif x[1] == 'in':
if len(x[2]) > 0:
@@ -486,7 +486,7 @@ class hr_attendance(osv.osv):
elif (x[2] is False) and (x[1] == '<>' or x[1] == '!='):
qu1.append('(s.id IS NOT NULL)')
else:
qu1.append('(s.id %s %s)' % (x[1], '%d'))
qu1.append('(s.id %s %s)' % (x[1], '%s'))
qu2.append(x[2])
elif x[1] == 'in':
if len(x[2]) > 0: