def _call_completed(self, cr, uid, data, context):
     debug(data)
     if data["form"]["user_id"] == uid and not data["form"]["call_summary"]:
         raise except_orm("Incomplete", "Please Provide Call Summary")
     if data["form"]["allocated_user_group_id"] and data["form"]["allocated_user_id"]:
         raise except_orm("Call Error!", "Both UserGroup And User Cannot Be Selected")
     if data["form"]["user_id"] != uid:
         if data["form"]["allocated_user_group_id"]:
             raise except_orm("Warning", "You Cannot Select the Group")
         data["form"]["allocated_user_id"] = data["form"]["user_id"]
     else:
         if not data["form"]["allocated_user_group_id"] and not data["form"]["allocated_user_id"]:
             raise except_orm("Call Error!", "Only one can be selected")
     person = pooler.get_pool(cr.dbname).get("cmc.person").browse(cr, uid, int(data["ids"][0]))
     user = pooler.get_pool(cr.dbname).get("res.users").browse(cr, uid, uid)
     data["form"]["call_date_time"] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     data["form"]["call_person_type"] = "agent"
     data["form"]["state"] = "closed"
     if not data["form"]["client_id"]:
         data["form"]["calling_about"] = "Self"
     else:
         cr.execute("select display_name from cmc_person where id=%d" % (data["form"]["client_id"]))
         d = cr.fetchone()
         data["form"]["calling_about"] = d[0]
     call_id = (
         pooler.get_pool(cr.dbname)
         .get("cmc.call.history")
         .create(cr, uid, data["form"], {"wizard": True, "person": person, "user": user})
     )
     return {}
 def _details(self, cr, uid, data, context):
     debug('==== DATA INFO PACK LETTER ====')
     prev_record = pooler.get_pool(cr.dbname).get('cmc.assessment').browse(cr, uid, int(data['ids'][0]))
     if prev_record.is_client:
         if prev_record.client_person_id.first_name :
             person_id = prev_record.client_person_id
     else:
         raise except_orm('Error','Following Assessment Has no Client')
         
     address1 = person_id.address_line_1
     address2 = person_id.address_line_2
     add=False
     if address1 :
         add=address1
     elif address2 :
         add=address2
     elif address1 and address2 :
         add=address1+','+address2
     postcode = person_id.postcode
     telephone = person_id.telephone
     email = person_id.email_address
         
     data['form']['location']=False
     data['form']['name']=person_id.display_name
     data['form']['birth_date']=person_id.birth_date
     data['form']['diagnosis']=prev_record.diagnosis if prev_record.diagnosis else False
     data['form']['assessment_date']=prev_record.assessment_date
     data['form']['owner']=prev_record.owner if prev_record.owner else False
     
     return data['form']
Пример #3
0
 def btn_booked(self, cr, uid, ids, context={}):
     debug(context)
     vals = {'state':'booked',
         }
     debug(ids)
     self.write(cr, uid, ids[0], vals, {'booked':'book'})
     return
def _create_equipment(self, cr, uid, data, context):
    if context.get('from',False) == 'call history':
        call_browse=pooler.get_pool(cr.dbname).get('cmc.call.history').browse(cr, uid, int(data['id']))
        details=False
        if call_browse.call_details:
            details=call_browse.call_details
        debug(details)
        if call_browse.client_id:
            person_id=call_browse.client_id.id
        else:
            raise except_orm('Warning','Following Record has no client')
    else:
        details=False
        person_id=int(data['id'])
    debug(person_id)
    return  {
            'domain': "[]",
            'name': 'Create New Equipment Enquiry',
            'view_type': 'form',
            'view_mode': 'form,tree',
            'res_model': 'cmc.equipement.supply.process',
            'view_id': False,
            'type': 'ir.actions.act_window',
            'context': {'person_id':person_id,
                        'details':details}
            }
 def _call_completed(self, cr, uid, data, context):
     if data['form']['user_id'] == uid and not data['form']['call_summary']:
         raise except_orm('Incomplete','Please Provide Call Summary')
     if data['form']['allocated_user_group_id'] and data['form']['allocated_user_id']:
             raise except_orm('Call Error!', 'Both UserGroup And User Cannot Be Selected')
     if data['form']['user_id'] != uid :
         if data['form']['allocated_user_group_id'] :
             raise except_orm('Warning','You Cannot Select the Group')
         data['form']['allocated_user_id']=data['form']['user_id']
     else:
         if not data['form']['allocated_user_group_id'] and not data['form']['allocated_user_id']:
             raise except_orm('Call Error!', 'Only one can be selected')
     person = pooler.get_pool(cr.dbname).get('cmc.person').browse(cr, uid, int(data['ids'][0]))
     user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid)
     debug(data)
     if data['form']['user_id'] == uid and not data['form']['call_summary']:
         raise except_orm('Incomplete','Please Provide Call Summary')
     data['form']['call_date_time'] = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
     data['form']['call_person_type'] = 'client'
     data['form']['agent_id'] = None
     data['form']['calling_about']='Self'
     data['form']['state'] = 'closed'
     call_id = pooler.get_pool(cr.dbname).get('cmc.call.history').create(cr, uid, data['form'],
                 {'wizard':True, 'person': person, 'user':user})
     return {}
 def _save(self, cr, uid, data, context):
     id = int(data['id'])
     if context.get('from',False) == 'call history':
        call_browse=pooler.get_pool(cr.dbname).get('cmc.call.hisoty').browse(cr, uid, id)
        person_id=call_browse.person_id.id
     else: 
         person_id=id
     if data['form']['user_id'] == uid and not data['form']['call_summary']:
         raise except_orm('Incomplete','Please Provide Call Summary')
     if data['form']['allocated_user_group_id'] and data['form']['allocated_user_id']:
             raise except_orm('Call Error!', 'Both UserGroup And User Cannot Be Selected')
     if data['form']['user_id'] != uid :
         if data['form']['allocated_user_group_id'] :
             raise except_orm('Warning','You Cannot Select the Group')
         data['form']['allocated_user_id']=data['form']['user_id']
     else:
         if not data['form']['allocated_user_group_id'] and not data['form']['allocated_user_id']:
             raise except_orm('Call Error!', 'Only one can be selected')
     debug("At Time of saving")
     debug(data)
     if data['form']['allocated_user_group_id'] and data['form']['allocated_user_id']:
         raise except_orm('Enquiry Error!', 'Both UserGroup And User Cannot Be Selected')
     person = pooler.get_pool(cr.dbname).get('cmc.person').browse(cr, uid, person_id)
     user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid)
     data['form']['call_date_time'] = datetime.datetime.now().strftime('%m/%d/%Y %H:%M:%S')
     data['form']['call_person_type'] = 'client'
     data['form']['state'] = 'allocated'
     data['form']['agent_id'] = None
     data['form']['calling_about']='Self'
     call_id = pooler.get_pool(cr.dbname).get('cmc.call.history').create(cr, uid, data['form'],
                 {'wizard':True, 'person': person, 'user':user})
     return {}
 def onchange_review_date(self, cr, uid, ids, time, context={}):
     values = {}
     values['value'] = {}
     time = int(time)
     debug(time)
     values['value']['review_date'] = (datetime.datetime.now() + datetime.timedelta(time * 365 / 12)).strftime("%Y-%m-%d")
     debug(values['value']['review_date'])
     return values
Пример #8
0
 def onchange_asset(self, cr, uid, ids, parent_id, context={}):
     values = {}
     debug(parent_id)
     values['value'] = {}
     if parent_id:
         values['value']['owner'] = parent_id
         values['value']['current_user_id'] = parent_id
     return values
    def _go_to_next_state(self, cr, uid, data, context):
         debug(data)
         debug(context)
         return {
            'name': 'Create New Assessment',
            'type': 'ir.actions.wizard',
            'wiz_name': 'next_state_assessment'

            }
 def _order_details(self, cr, uid, data, context):
     debug(context)
     data['form']['workshop_id']=data['id']
     pool = pooler.get_pool(cr.dbname)
     picking_obj = pool.get('cmc.workshop.part.ordered')
     ids=picking_obj.search(cr, uid, [('workshop_id', '=', data['id'])])
     if len(ids)==0:
         raise except_orm('Warning','This record has no part ordered')
     debug(data)
     return data['form']
Пример #11
0
 def _id_default(self, cr, uid, context={}):
     debug(context)
     query = "select id from cmc_person where display_name='East Anglia Drive Centre'"
     cr.execute(query)
     ids = cr.fetchone()
     debug(ids)
     if ids is not None :
         return ids[0]
     else:
         return False
 def _go_to_menu(self, cr, uid, data, context):
     debug(uid)
     return  {
         'name': 'Action Records',
         'view_type': 'form',
         'view_mode': 'tree',
         'res_model': 'cmc.enquiry',
         'view_id': False,
         'type': 'ir.actions.act_window',
         }
Пример #13
0
 def create(self, cr, uid, vals, context):
     debug(vals)
     if 'workshop_id' in vals:
         pooler.get_pool(cr.dbname).get('cmc.workshop.task.history').create(cr, uid, {
                                                                     'date_task':datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
                                                                     'title':'Part Order',
                                                                     'description':'Part ' + str(vals['part_no'] if vals['part_no'] > 0  else "") + 'Has Been Ordered on ' + (vals['date_order'] if vals['date_order'] else ""),
                                                                     'workshop_id':vals['workshop_id']   
                                                                                    })
     return super(cmc_workshop_part_ordered, self).create(cr, uid, vals, context)
 def _save(self, cr, uid, data, context):
     debug(data)
     debug(context)
     data['form']['equipment_supply_process_id']=data['id']
     data['form']['state']='Ordered'
     data['form']['date_ordered']=datetime.datetime.now().strftime("%Y-%m-%d")
     if not data['form']['owner_id']:
         data['form']['owner']=context.get('client_id',False)
     else:
         data['form']['owner']=data['form']['owner_id']
     enquiry_id = pooler.get_pool(cr.dbname).get('cmc.ordered.equipment.master').create(cr, uid, data['form'],context)
     return data['form']
 def _save(self, cr, uid, data, context):
     debug(self)
     pooler.get_pool(cr.dbname).get('cmc.enquiry').write(cr, uid, int(data['id']), {'state':'closed'}, context=context)
     seq_id = pooler.get_pool(cr.dbname).get('ir.sequence').search(cr, uid, [('name', '=', 'CMC Assessment')])[0]
     new_id = pooler.get_pool(cr.dbname).get('ir.sequence').get_id(cr, uid, seq_id)
     ref_id = str(new_id)
     enquiries = pooler.get_pool(cr.dbname).get('cmc.enquiry').browse(cr, uid, int(data['id']))
     enquiry=enquiries
     enquiry_id = enquiry.id
     driving = enquiry.enquiry_type
     state_id=data['form']['state']
     search_state=pooler.get_pool(cr.dbname).get('cmc.assessment.state').browse(cr,uid,state_id)
     if enquiry.is_dvla:
         referrer_type='dvla'
     elif enquiry.is_client:
         referrer_type='client_family'
     data['form']['total_cost']=0;
     price_id=pooler.get_pool(cr.dbname).get('cmc.assessment.price').search(cr, uid, [('type', '=',driving)])
     if len(price_id) >0:
         price_browse=pooler.get_pool(cr.dbname).get('cmc.assessment.price').browse(cr, uid, price_id[0])
         data['form']['total_cost']=price_browse.price
     id = pooler.get_pool(cr.dbname).get('cmc.assessment').create(cr, uid, {
              'ref_id':ref_id,
              'agent_person_id':enquiry.agent_id.id if enquiry.agent_id.id else None,
              'client_person_id':enquiry.client_id.id if enquiry.client_id.id else None,
              'person_id':enquiry.person_id.id,
              'enquiry_id':enquiry.id,
              'enquiry_details':enquiry.enquiry_details,
              'paying':enquiry.paying,
              'driving_assessment_type':driving,
              'assessment_date': datetime.datetime.now(),
              'state':state_id,
              'is_agent':enquiry.is_agent,
              'is_client':enquiry.is_client,
              'is_dvla':enquiry.is_dvla,
              'referrer_type':referrer_type,
              'appointment_letters':'New appointment letter to Client post',
              'total_cost':data['form']['total_cost']
             })
     person = False
     person=enquiry.person_id
     id = int(id)
     debug(person.id)
     pooler.get_pool(cr.dbname).get('cmc.assessment.communication').create(cr, uid, {
              'comm_date':datetime.datetime.now(),
              'assessment_id':id,
              'type':self.drving_name(driving),
              'client_name':enquiry.person_id.id,
              'user_id':uid,
              'subject':'Assessment Record Created with ' + ref_id,
              'message':'State Changed to '+search_state.name
             })
     return {}
Пример #16
0
 def update_freespace(self, cr, uid, target, path=None):
     storage_obj = self.pool.get('backup.storage')
     if target.freespace_code:
         localdict = {
             'path': path or target.path,
         }
         exec target.freespace_code in localdict
         from tools.misc import debug
         debug(localdict['freespace'])
         if 'freespace' in localdict:
             storage_obj.write(cr, uid, target.storage_id.id,
                 {'freespace': localdict['freespace']})
Пример #17
0
 def _get_default_detail(self, cr, uid, ids, field_name, arg, context={}):
     result = {}
     debug("Assessment Appointment Owner")
     if len(ids) > 0 :
         for id in ids:
             result[id]=False
             q='select owner from cmc_appointments where assessment_id=%d and (state=\'active\' or state=\'active_clash\') order by apmnt_start_date_time desc' %(id)
             cr.execute(q)
             ee=cr.fetchall()
             debug(ee)
             if ee is not None and len(ee)>0:
                 result[id]=ee[0][0]
     return result
Пример #18
0
 def _client_details(self, cr, uid, data, context):
     debug(context)
     if context.get('cancel', False) == 'equipment' or context.get('cancel', False) == 'workshop':
         data['form']['come_from'] = False
     else:
         data['form']['come_from'] = True
     app_record = pooler.get_pool(cr.dbname).get('cmc.appointments').browse(cr, uid, data['id'])
     data['form']['title'] = app_record.title
     data['form']['from_date'] = app_record.apmnt_start_date_time
     data['form']['to_date'] = app_record.apmnt_end_date_time
     data['form']['location'] = app_record.location 
     data['form']['status'] = app_record.state
     return data['form']
def _print_send_information_pack(self, cr, uid, data, context):
    debug("I AM IN PRINT IFORMATION PACK")
    debug(context)
    return {
        "domain": """[('state', '=', 'pending'),
                        ('enquiry_type','!=','general')]""",
        "name": "Print and Send Information Pack",
        "view_type": "form",
        "view_mode": "tree,form",
        "res_model": "cmc.enquiry",
        "view_id": False,
        "type": "ir.actions.act_window",
    }
Пример #20
0
 def btn_save(self, cr, uid, ids, context={}):
     cr.execute('select id from ir_ui_menu where name=\'Action Handling\'')
     view = cr.fetchone()
     debug(view)
     return    {
         'name': 'Actions Allocated To Me',
         'view_type': 'form',
         'view_mode': 'tree,form',
         'res_model': 'cmc.enquiry',
         'view_id': False,
         'type': 'ir.actions.act_window',
         'context': {'user_id':uid}
         }
def _appointments(self, cr, uid, data, context):
    debug("=====DEBUG======")
    query=[]
    usr=[]
    usr = data['form']['user'][0][2]
    equip=data['form']['equipment'][0][2]
    
    group=False
    user_ids=False
    equipment=False
    users_group=[]
    user_len = len(usr)
    if (user_len > 0 or data['form']['user_group']) and not data['form']['equipment']:
        title = 'User Equipment Appointment Diary'
    else:
        title = 'Appointment Diary'
    if data['form']['user_group']:
        cr.execute('select uid from res_groups_users_rel where gid = %s' %(str(data['form']['user_group'])))
        ret_group=cr.fetchall()
        if ret_group >0:
            users_group=[x[0] for x in ret_group]  
        group=True
    usr.extend(users_group)
    user_len = len(usr)
    
    if user_len > 0 :
        user_ids=True
        query.append('select id from cmc_appointments where type not in (\'reminder\') and state not in (\'cancelled\',\'cancelled_within_two_days\') and (owner in ('+ ','.join([str(u) for u in usr]) +') or id in (select appointment_id from user_appointment_rel  where user_id in ('+','.join([str(u) for u in usr]) + ')))')
    equipment=False
    if len(equip) >0 :
        equipment=True
        query.append('select appointment_id from equipment_appointment_rel where equipment_id in ('+ ','.join([str(u) for u in equip]) +')')
    if len(query) == 0:
        cr.execute("select id from cmc_appointments where type not in ('reminder') and state not in (\'cancelled\',\'cancelled_within_two_days\')")
        data['form']['all_search']=True
    else:
        cr.execute(' union '.join(query))
        data['form']['all_search']=False
    my_appointments = cr.fetchall()
    debug(data)
    
    return  {
            'name': title,
            'view_type': 'form',
            'view_mode': 'calendar,form,tree',
            'res_model': 'cmc.appointments',
            'view_id': False,
            'type': 'ir.actions.act_window',
            'domain': "[('id','in',%s)]" % str(my_appointments),
            'context':{'app_data':data['form']}
        }
Пример #22
0
 def create(self, cr, uid, vals, context={}):
     self.validate(vals)
     seq_id = self.pool.get('ir.sequence').search(cr, uid, [('name',
                                                             '=',
                                                             'CMC Person')])[0]
     new_id = self.pool.get('ir.sequence').get_id(cr,
                                                  uid,
                                                  seq_id)
     if vals['is_organisation']:
         vals['is_agent'] = True
         if vals['organisation_name']==tools.config.options['organisation_name']:
             vals['is_dvla']=True
     vals['person_id'] = str(new_id)
     vals['state'] = 'created'
     if not vals['display_name']:
         if vals['first_name'] and vals['last_name']:
             vals['display_name'] = (vals['first_name']) + ' ' + (vals['last_name'])
         elif vals['is_organisation']:
             vals['display_name'] = vals['organisation_name'] if vals['organisation_name'] else False
     address_line_1 = vals['address_line_1']
     address_line_2 = vals['address_line_2']
     city = vals['city']
     county = vals['county']
     postcode = vals['postcode']
     if address_line_1 and not postcode:
         raise except_orm('Warning','Please Enter Postcode')
     address_type = vals['address_type'] 
     telephone_type = vals['telephone_type'] 
     telephone = vals['telephone']
     extension = vals['extension']
     telephone_description = vals['telephone_description'] 
     email_type = vals['email_type'] 
     email_address = vals['email_address']
     id = super(cmc_person, self).create(cr, uid, vals, context)
     activity_table = pooler.get_pool(cr.dbname).get('cmc.user.activity')
     if not vals['is_organisation']:
         activity_table.create(cr, uid, {
                            'date': datetime.datetime.now(),
                            'user_id': uid,
                            'type': 'Person Record',
                            'activity':'New Person Created',
                            'person_id':int(id)})
     else:
         activity_table.create(cr, uid, {
                            'date': datetime.datetime.now(),
                            'user_id': uid,
                            'type': 'Organisation Record',
                            'activity':'New Organisation Created',
                            'person_id':id})
         debug(vals)
     return id
Пример #23
0
 def _get_enquiry_ids(self, cr, uid, ids, field_name, arg, context={}):
     debug('Check I am here')
     res = {}
     for id in ids:
         cr.execute('SELECT e.id FROM cmc_enquiry e WHERE e.client_id=%s OR e.agent_id=%s',
                (str(id), str(id)))
         calls = cr.fetchall()
         if not calls:
             res[id] = []
             continue
         else: 
             res[id] = [x[0] for x in calls]
     debug(res)
     return res
Пример #24
0
def _reception_enquiries(self, cr, uid, data, context):
    cr.execute("select id from cmc_enquiry where state in ('pending','awating') and (allocated_user_group_id in (select id from res_groups where name != 'Mobility ILME User') or allocated_user_group_id is null)")
    ids=cr.fetchall()
    debug(ids)
    return  {
            'domain': "[('id','in',%s)]" % str(ids),
            'name': 'Reception Enquiries - Pending Action',
            'view_type': 'form',
            'view_mode': 'tree,form',
            'res_model': 'cmc.enquiry',
            'view_id': False,
            'type': 'ir.actions.act_window',
            'context': {'user_id':uid}
            }
def _my_calls(self, cr, uid, data, context):
    debug(data)
    cr.execute('select id from ir_ui_view where model=%s and name=%s', ('cmc.call.history', 'view_cmc_call_history_tree'))
    view_res = cr.fetchone()
    return  {
            'domain': "[('allocated_user_id','=',%d), ('state', '=', 'allocated')]" % (uid),
            'name': 'Calls Allocated to Me',
            'view_type': 'form',
            'view_mode': 'tree,form',
            'res_model': 'cmc.call.history',
            'view_id': view_res,
            'type': 'ir.actions.act_window',
            'context': {'user_id':uid}
            }
 def _go_to_menu(self, cr, uid, data, context):
     debug(data['form']['equipment_id'])
     if context.get('equipment_supply',False) != 'Equipment Supply':
         return  {
                 'name': 'Workshop Task',
                 'view_type': 'form',
                 'res_model': 'cmc.workshop.process',
                 'view_mode': 'form,tree',
                 'res_id': data['form']['equipment_id'],
                 'view_id': False,
                 'type': 'ir.actions.act_window'
                 }
     else:
         return {}
Пример #27
0
 def write(self, cr, uid, ids, vals, context={}):
     debug("<<EQUIPMENT WRITE MODE>>")
     debug(vals)
     debug(ids)
     if not context.get('booked', False) or not context.get('bypass', False):
         prev_record = self.browse(cr, uid, ids[0])
         owner_table = pooler.get_pool(cr.dbname).get('cmc.user.owner.equipment.history')
         #===================================================================
         # Equipment checking 
         #===================================================================
         if 'owner' in vals:
             if vals['owner'] != prev_record.owner.id :
                 owner_table.create(cr, uid, {
                                                'name':prev_record.owner.display_name,
                                                'name_owner_id':prev_record.id,
                                                'date_ownership':datetime.datetime.now().strftime("%Y-%m-%d"),
                                                'person_id':prev_record.owner.id
                                                })
                                                
             if not vals['current_user_id'] and (prev_record.owner.display_name=='North East Drive Mobility' or prev_record.owner.display_name=='PCT Assets'):
                 debug("Found")
                 vals['state']='in_stock'
             else:
                 vals['state']='external'   
             if vals['current_user_id'] != prev_record.current_user_id.id :
                 owner_table.create(cr, uid, {
                                                'name':prev_record.current_user_id.display_name,
                                                'name_history_id':prev_record.id,
                                                'date_ownership':datetime.datetime.now().strftime("%Y-%m-%d"),
                                                'person_id':prev_record.current_user_id.id
                                                })
     return super(cmc_equipment, self).write(cr, uid, ids, vals, context)
 def _go_to_menu(self, cr, uid, data, context):
     #        cr.execute('select id, name from ir_ui_view where model=%s and name=%s', ('cmc.call.history', 'view_cmc_my_call_tree'))
     #        view_res = cr.fetchone()
     debug(uid)
     return {
         "domain": "[]",
         "name": "Find a Person or Organisation",
         "view_type": "form",
         "res_model": "cmc.person",
         "view_mode": "form,tree",
         "res_id": int(data["id"]),
         "view_id": False,
         "type": "ir.actions.act_window",
         "context": {"by_pass": "******"},
     }
    def _go_to_menu(self, cr, uid, data, context):
#        cr.execute('select id, name from ir_ui_view where model=%s and name=%s', ('cmc.call.history', 'view_cmc_my_call_tree'))
#        cr.execute('select id, name from ir_ui_view where model=%s and name=%s', ('cmc.call.history', 'view_cmc_person_tree'))
#        view_res = cr.fetchone()
        debug(uid)
        return  {
                'domain': "[]",
                'name': 'Find a Person or Organisation',
                'view_type': 'form',
                'res_model': 'cmc.person',
                'view_mode': 'form,tree',
                'res_id': int(data['id']),
                'view_id': False,
                'type': 'ir.actions.act_window'
                }
Пример #30
0
def _my_enquiries(self, cr, uid, data, context):
#    cr.execute('select id, name from ir_ui_view where model=%s and name=%s', ('cmc.enquiry', 'view_cmc_my_enquiry_tree'))
#    view_res = cr.fetchone()
    debug(data)
    debug(self)
    return  {
            
            'name': 'All Actions',
            'view_type': 'form',
            'view_mode': 'tree,form',
            'res_model': 'cmc.enquiry',
            'view_id': False,
            'type': 'ir.actions.act_window',
            'context': {'user_id':uid}
            }
Пример #31
0
        cid = rc and rc.name or valid_contracts[0].name
        try:
            # as backup, put it also in another database...
            import urllib
            args = urllib.urlencode({
                'contract_id': cid,
                'crm_case_id': crm_case_id or 0,
                'explanation': explanations,
                'remark': remarks or '',
                'tb': tb,
            })
            uo = urllib.urlopen(
                'http://www.openerp.com/scripts/maintenance.php', args)
            submit_result = uo.read()
            debug(submit_result)
            uo.close()
        except:
            if not crm_case_id:
                # TODO schedule a retry (ir.cron)
                return False
        return True

    def _valid_get(self, cr, uid, ids, field_name, arg, context=None):
        res = {}
        for contract in self.browse(cr, uid, ids, context=context):
            res[contract.id] = (
                "unvalid",
                "valid")[contract.date_stop >= time.strftime('%Y-%m-%d')]
        return res