This is the source with error.. Kindly review and get back to me ... Thanks in advance ...
Code:
class employee_role_project(osv.osv):
_name = 'custom.user.project.acces'
_description = "Custom User Project Acces"
_columns = {
'div_code_id': fields.many2one('custom.project.division', 'Division Name',required=True, domain="[('name','!=',''),('isdefault','!=',1)]"),
'project_id': fields.many2one('project.project', 'Project Name', required=True, domain="[('div_code_id','=',div_code_id)]"),
'role_id': fields.many2one('custom.user.details', 'Project Name',ondelete='cascade'),
}
def create(self, cr, uid, vals, context=None):
project_pool = self.pool.get('project.structure')
aprt_type_pool = self.pool.get('custom.apartment.type')
price_list_type_pool = self.pool.get('custom.price.list.type')
price_list_pool = self.pool.get('custom.price.list')
cpss_pool = self.pool.get('custom.payment.schedule.stages')
cpsh_pool = self.pool.get('custom.payment.schedule.header')
user_pool = self.pool.get('custom.user.details')
acc_vou_pool = self.pool.get('account.voucher')
acc_mov_pool = self.pool.get('account.move')
acc_journal_pool = self.pool.get('account.journal')
acc_batch_pool = self.pool.get('custom.voucher.batch.hdr')
usr_ids = user_pool.search(cr, uid, [('id','=',vals.get('role_id'))])
div_ids = self.search(cr, uid, [('div_code_id','=',vals.get('div_code_id')),('project_id','=',vals.get('project_id')),('role_id','=',vals.get('role_id'))])
if div_ids:
raise osv.except_osv(_('Invalid!'), _('Division and Project Should be unique for a User!'))
for s in user_pool.browse(cr, uid, usr_ids, context):
if div_ids:
raise osv.except_osv(_('Invalid!'), _('Division and Project Should be unique for a User!'))
if s:
cr.execute('select * from custom_division_user_rel where div_code_id=%s and uid=%s',(vals.get('div_code_id'),s.user_id.id))
res = cr.fetchall();
if not res:
cr.execute('insert into custom_division_user_rel(div_code_id,uid) values(%s,%s)', (vals.get('div_code_id'),s.user_id.id))
#pro_str_ids = project_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
#for pro_str in project_pool.browse(cr, uid, pro_str_ids, context):
# cr.execute('insert into project_structure_user_rel(project_structure_id,uid) values(%s,%s)', (pro_str.id,s.user_id.id))
pro_str_ids = project_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
for pro_str in project_pool.browse(cr, uid, pro_str_ids, context):
cr.execute('insert into project_structure_user_rel(project_structure_id,uid) values(%s,%s)', (pro_str.id,s.user_id.id))
aprt_type_ids = aprt_type_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
for aprt_type in aprt_type_pool.browse(cr, uid, aprt_type_ids, context):
#raise osv.except_osv(_('Error!'), _('%s-%s')%(aprt_type.id,s.user_id.id,))
cr.execute('insert into custom_apartment_type_user_rel(apartment_type_id,uid) values(%s,%s)', (aprt_type.id,s.user_id.id))
price_list_type_ids = price_list_type_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
for pri_lst_type in price_list_type_pool.browse(cr, uid, price_list_type_ids, context):
cr.execute('insert into custom_price_list_type_user_rel(price_list_type_id,uid) values(%s,%s)', (pri_lst_type.id,s.user_id.id))
price_list_ids = price_list_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
for pri_lst in price_list_pool.browse(cr, uid, price_list_ids, context):
cr.execute('insert into custom_price_list_user_rel(price_list_id,uid) values(%s,%s)', (pri_lst.id,s.user_id.id))
cpss_ids = cpss_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
for cps_stage in cpss_pool.browse(cr, uid, cpss_ids, context):
cr.execute('insert into custom_payment_schedule_stages_user_rel(payment_schedule_stage_id,uid) values(%s,%s)', (cps_stage.id,s.user_id.id))
cpsh_ids = cpsh_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
for cps_header in cpsh_pool.browse(cr, uid, cpsh_ids, context):
cr.execute('insert into custom_payment_schedule_header_user_rel(payment_schedule_header_id,uid) values(%s,%s)', (cps_header.id,s.user_id.id))
acv_ids = acc_vou_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
for acv in acc_vou_pool.browse(cr, uid, acv_ids, context):
cr.execute('insert into account_voucher_rel(account_voucher_id,uid) values(%s,%s)', (acv.id,s.user_id.id))
acm_ids = acc_mov_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
for acm in acc_mov_pool.browse(cr, uid, acm_ids, context):
cr.execute('insert into account_move_rel(account_move_id,uid) values(%s,%s)', (acm.id,s.user_id.id))
acj_ids = acc_journal_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
for acj in acc_journal_pool.browse(cr, uid, acj_ids, context):
cr.execute('insert into account_journal_rel(account_journal_id,uid) values(%s,%s)', (acj.id,s.user_id.id))
batch_ids = acc_batch_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
for batch in acc_batch_pool.browse(cr, uid, batch_ids, context):
cr.execute('insert into custom_voucher_batch_hdr_rel(custom_voucher_batch_hdr_id,uid) values(%s,%s)', (batch.id,s.user_id.id))
#raise osv.except_osv(_('Invalid action !'), _('%s,%s')%(vals.get('project_id'),s.user_id.id))
return super(employee_role_project, self).create(cr, uid, vals, context=context)