Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No eliminar registros de mailbox en el read #17

Open
polsala opened this issue Nov 16, 2022 · 0 comments
Open

No eliminar registros de mailbox en el read #17

polsala opened this issue Nov 16, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@polsala
Copy link
Member

polsala commented Nov 16, 2022

Caso de uso:
- Varias facturas (antiguas) apuntavan a mailboxes con referencias a otras facturas que ya no existian
- Al listar dichas facturas, acababa ejecutando un read sobre el modelo de mailbox
- Al ver que el reference de esa mailbox apuntava a una factura que no existia intentava eliminar la entrada
- Como la operacion era readonly no podia

Particularidades del caso de uso:
- Realmente en este caso, aun que fuse una tranacción normal, ubiera terminado lanzando un error de Foreign-key, ya que estaba referenciada por otras facturas tambien giscedata_facturacio_factura_mailbox_fkey

poweremail_references/poweremail_mailbox.py

En caso de que este read se origine en una transaccion readonly, fallara

    def read(self, cursor, uid, ids, fields=None, context=None, load='_classic_read'):
        if context is None:
            context = {}
        select = ids
        if isinstance(ids, six.integer_types):
            select = [ids]
        valid_select = []
        for id in select:
            res = self.validate_referenced_object_exists(cursor, uid, [id], fields, context=None)
            if res:
                valid_select.append(id)
            else:
-------------->super(PoweremailMailbox,
                        self).unlink(cursor, uid, [id], context)
        ret = []
        if valid_select:
            ret = super(PoweremailMailbox,
                        self).read(cursor, uid, valid_select, fields, context, load)
        if isinstance(ids, six.integer_types) and ret:
            return ret[0]
        return ret
@polsala polsala self-assigned this Nov 16, 2022
@polsala polsala added the bug Something isn't working label Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant