Esempio n. 1
0
def reset_password(session, model_name, binding_id, template_id,
                   date_validity):
    binding = session.env[model_name].browse(binding_id)
    token = binding._reset_password(template_id, date_validity)
    env = get_environment(session, model_name, binding.backend_id.id)
    adapter = env.get_connector_unit(CRUDAdapter)
    adapter.write(binding.external_id, {
        '_auth_reset_token': token,
        '_auth_reset_sent_at': date_validity,
    })
    return 'Reset Password Sent'
Esempio n. 2
0
def clear_dead_content(session, model_name, backend_id):
    env = get_environment(session, model_name, backend_id)
    adapter = env.get_connector_unit(CRUDAdapter)
    binder = env.get_connector_unit(Binder)
    page = 1
    while True:
        data = adapter.search(page=page)
        if not data:
            break
        page += 1
        for content in data:
            if not binder.to_openerp(content['_id']):
                export_delete_record.delay(session, model_name, backend_id,
                                           content['_id'])
Esempio n. 3
0
 def _get_service(self, record, service_class):
     session = ConnectorSession.from_env(self.env)
     env = get_environment(session, record._name, self.backend_id.id)
     service = env.backend.get_class(service_class, session, record._name)
     return service(env, None, {})
Esempio n. 4
0
 def _get_service(self, service_class, partner):
     model_name = service_class._model_name
     session = ConnectorSession.from_env(self.env)
     env = get_environment(session, model_name, self.backend.id)
     service = env.backend.get_class(service_class, session, model_name)
     return service(env, partner, self.shopinvader_session)