5 Commits
Author SHA1 Message Date
mega cf16b96ae0 [FIX] sale_loyalty: prevent error while remove all product quantities from cart
Currently, an error is generated when removing all product quantities from the
cart after a claiming a reward(discount).

Step to produce:

- Install a 'website_sale_loyalty' module.
- Navigate to the website / eCommerce / Loyalty / Discount & Loyalty to create
a record.
- Set the Loyalty Program name and Program Type as 'Loyalty Cards'.(Ensure it's
available on sale and the website.)
-  And add 'Rewards' and set a Reward Type as 'Discount' which is applied to
on Cheapest Product.
 - Go to the website shop add any product on a card, Open a cart increase the
 quantity of the product, and claim the discount reward.
- Again go to Loyalty Program and open Loyalty Card, Open a record and add a
Balance(greater than 200 as default reward points are 200) and copy 'Code'.
- Again go to the website shop and apply this code to claim a discount after a
claim discount.
- Now remove all product quantity from a cart.

AttributeError: 'bool' object has no attribute 'price_unit'

The issue occurs when attempting to remove all product quantities from a cart.
At this point [1], a bool value  'False' is returned, and the system attempts to
get a value of 'price_unit' from it [2].

link [1]: https://github.com/odoo/odoo/blob/499056a82db26f7d9caa86314e666e2bd49cc79c/addons/sale_loyalty/models/sale_order.py#L187-L195

link [2]: https://github.com/odoo/odoo/blob/499056a82db26f7d9caa86314e666e2bd49cc79c/addons/sale_loyalty/models/sale_order.py#L205

This commit resolve issue, If the _cheapest_line() method returns False then
also returns False from _discountable_cheapest(), To raise an error at [3].

link [3]:  https://github.com/odoo/odoo/blob/cbc40eccf576c499709f7825edad9a3b3ce7a22d/addons/sale_loyalty/models/sale_order.py#L317-L333

sentry-5119007021

closes odoo/odoo#163403

X-original-commit: dfd1aabb40d8c8e6e80f1b194a4b61e1dfb41608
Signed-off-by: Meet Gandhi (mega) <mega@odoo.com>
2024-04-26 10:05:19 +00:00
mega 67dc32b61f [FIX] l10n_id_efaktur: prevent error when download e-Faktur without tax number
Currently, the error arises when downloading e-Faktur without a 'Tax Number'.

Steps to reproduce:

- Install a 'l10n_id_efaktur' module (with demo data).
- Navigate to Invoicing -> Customers -> Invoices and open any invoice with
an empty 'Tax Number' field.
- Click on the action button to download e-Faktur.

Error:   'bool' object is not subscriptable while evaluating
'action = records.download_efaktur()'

When downloading e-Faktur, There's an issue at [1], Where
the system tries to access elements of 'l10n_id_tax_number', but
'Tax Number' is empty, So 'l10n_id_tax_number' is considered as a 'False'.

[1]: https://github.com/odoo/odoo/blob/9c4194ad3387c55d39ec7bbef1c6414893098c6e/addons/l10n_id_efaktur/models/account_move.py#L168-L170

This commit fixes the above issue by adding a condition to ensure that
the system only accesses an 'l10n_id_tax_number' if it is available.

sentry-5001664034

closes odoo/odoo#162749

X-original-commit: 24e65c2fe904e9a2a4e5004dc0e7ada220d1dacc
Signed-off-by: William André (wan) <wan@odoo.com>
2024-04-21 18:14:37 +00:00
mega-odoo 58f7cbc1ef [FIX] website_payment: handle an error for empty donation amount
When a user pays a donation with an empty amount value, the system
passes this value as an empty string, which is leading to a type-casting error
because an empty string cannot be directly converted to a numerical value like
a float.

Error: `ValueError: could not convert string to float: `

To handle this situation, we should use '_cast_as_int' and
'_cast_as_float' methods because these methods provide try-except blocks,
effectively handling these types of errors. This ensures that when an empty
amount value is encountered, the system manages the error.

sentry-4376573159

closes odoo/odoo#134026

X-original-commit: cae9f647b9e032aedfccc528d124acc639ecbf7f
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2023-09-01 17:53:48 +00:00
mega-odoo c5290e5427 [FIX] l10n_gcc_invoice: prevent trace back while printing an invoice
'ZeroDivisionError: float division by zero' is generated if the user prints
an invoice pdf without including an invoice line or invoice line with the
product price 0.

Steps to Reproduce

- Install the 'l10n_gcc_invoice' modules.
- Go to the current company and change the country to any Gulf nation, such
as Bahrain, Kuwait, Oman, Qatar, Saudi Arabia, or the United Arab Emirates if
it isn't already.
- Go to Accounting > Configuration > Accounting > Currencies
- Activate another currency.
- Open an 'Invoices' module
- Add the 'currency_id' field in the invoice form view.
- Create a new invoice except including the invoice line or invoice line with
 product price 0 and select a currency that does not equal the current company
currency.
- And print this invoice.

Applying this commit will resolve this issue.

sentry-4210558233

closes odoo/odoo#125502

X-original-commit: ae9de44b91b7e80b4a44d69afa69ca95d8f528fe
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
Signed-off-by: Josse Colpaert <jco@odoo.com>
2023-06-22 15:41:03 +02:00
mega-odoo e502b972c8 [FIX] web_editor: prevent error when edit the float, monetary section in website
'replace() argument 1 must be str, not bool' is generated if the user edit a
float or monetary section in the website view.

Steps to Reproduce

- Make debugger mode ON.
- Go to Settings > Translations > Languages.
- Remove the value of the 'Thousands Separator' field from the current user
language.
- Install the 'eCommerce' module.
- Go to the website.
- Go to the shop menu, and click any product from the product list.
- Click on the Edit button and try to edit any float or
monetary section like a product price (eg. change a product price from 750 to
70) and click on the Save button.

And traceback will be generated.

Applying this commit will resolve this issue.

sentry-4148693017

closes odoo/odoo#125684

X-original-commit: b895175cfc487f3db6e53351fd5774303f193698
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-06-20 09:11:01 +02:00