Files
odoo_source/addons/loyalty/views
Paul Stroobant 9a9a44eec0 [FIX] loyalty: remove loyalty.card creation through contacts
Steps to reproduce issue:

1. Select a Contact
2. Click on Smart Button "Loyalty Cards"
3. Create a new Loyalty Coupon
4. Save
5. Receive an error:

>     The operation cannot be completed: another model requires the record being deleted. If possible, archive it instead.
>
>     Model: Loyalty Coupon (loyalty.card)
>     Constraint: loyalty_card_program_id_fkey

Explanation:

The model given to `program_id` by the `default` attribute is not always `loyalty.program`. In the case of the issue, for example, the model is `res.partner`.
https://github.com/odoo/odoo/blob/a3201d636505dc1976d3f0ee7f8cbf65d2488966/addons/loyalty/models/loyalty_card.py#L27

Suggested fix:

The creation of `loyalty.card` from `res.partner` Smart Button is not intended, therefore we will remove this option and set the Smart Button as invisible if `loyalty_card_count` is null.

opw-3707588

closes odoo/odoo#154258

X-original-commit: 8645874ec0e7ae81f032231be4908e173d2a4043
Signed-off-by: Stroobant Paul (stpa) <stpa@odoo.com>
2024-02-16 12:12:47 +00:00
..