Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
4972 Vistas

Module note, note.py, line~ 82.

If your create Note with stage, function _get_default_stage_id return first stage. But note not create yet and access rule say "access denied".

Why get first stage? Because before if you add new note and you have some stages but you not set stage manual when create note, system put note to "undefined" stage. And it way to can't show Note. After sometime, add new futures - it possible show new note with "undefined" stage in first stage. It works. Onetime it stop working. But you remember we have possible show note with "undefined" stage.

If some change

    def _get_default_stage_id(self,cr,uid,context=None):
        ids = self.pool.get('note.stage').search(cr,uid,[('user_id','=',uid)], context=context)
        #return ids and ids[0] or False
        return False

Now create new note with "undefined" stage, save that. After you can change stage what you wont.

Avatar
Descartar
Autor Mejor respuesta

Second part.

When note create some function from email check followers, but we have access rule

<record id="note_note_rule_global" model="ir.rule"> <field name="name">Only followers can access a sticky notes</field> <field model="ir.model" ref="model_note_note" name="model_id"/> <field name="domain_force">[('message_follower_ids','=',user.partner_id.id)]</field> <field eval="True" name="global"/> <field eval="1" name="perm_unlink"/> <field eval="0" name="perm_write"/> <field eval="1" name="perm_read"/> <field eval="0" name="perm_create"/> </record>

it can't add note without error Access check. What need. Need add create. It add follower for new note before system check follower for new note.

note.py for class note_note(osv.osv):

def create(self, cr, uid, vals, context=None):

    new_id = super(note_note, self).create(cr, uid, vals, context=context)

    res_users_obj = self.pool.get('res.users')
    res_users_ids = res_users_obj.read(cr, uid, uid, ['partner_id'], context=None)

    if res_users_ids:

        partner_id_print = res_users_ids['partner_id'][0]
        res_follower_obj = self.pool.get('mail.followers')

        res_follower_id = res_follower_obj.create(cr, uid,
        { 'res_model': 'note.note',
          'res_id' : new_id,
          'partner_id': partner_id_print ,
        })

    return new_id
Avatar
Descartar
Autor

But now we have problem with access to mail.follower. Temporary need grand access for creat to ( mail.followers.al , mail.followers.user)

Publicaciones relacionadas Respuestas Vistas Actividad
4
mar 15
8160
2
mar 15
4270
0
mar 15
3346
0
ene 25
886
0
sept 22
2890