[FW][IMP] test_mail: test models with type do not mess with attachment types
Purpose of this commit is to highlight an issue that may happens easily with `crm` that is made generic here within `test_mail`. `crm` alters the context when creating a new record adding in this case `default_type` to it][1]. The returned record contains that altered context. his results in other records created from it trying to assign that same default value for `type`. This is a very common name for fields, and happens to exist in `ir.attachment` too. If you create an alias for incoming leads in your DB with default values `{"type": "lead"}` (something very common) and then an email comes to that alias that contains an inlined base64 image, the attachment creation process would simply fail. Obtained error is ``ValueError: Wrong value for ir.attachment.type: 'lead'`` . [1]: https://github.com/odoo/odoo/blob/272602193f5647f7f2270ed6ec68777625a139dd/addons/crm/models/crm_lead.py#L310-L311 closes odoo/odoo#74410 X-original-commit: odoo/odoo@a757439650bb3eb8de3bda087324ef5363d671a8 Signed-off-by:Thibault Delavallee (tde) <tde@openerp.com> Co-authored-by:
Thibault Delavallee <tde@odoo.com>
Showing
- addons/test_mail/data/test_mail_data.py 44 additions, 0 deletionsaddons/test_mail/data/test_mail_data.py
- addons/test_mail/models/__init__.py 4 additions, 1 deletionaddons/test_mail/models/__init__.py
- addons/test_mail/models/test_mail_corner_case_models.py 26 additions, 0 deletionsaddons/test_mail/models/test_mail_corner_case_models.py
- addons/test_mail/security/ir.model.access.csv 2 additions, 0 deletionsaddons/test_mail/security/ir.model.access.csv
- addons/test_mail/tests/common.py 4 additions, 4 deletionsaddons/test_mail/tests/common.py
- addons/test_mail/tests/test_mail_gateway.py 49 additions, 0 deletionsaddons/test_mail/tests/test_mail_gateway.py
Loading
Please register or sign in to comment