Name: [FIX] pos_loyalty: keep reward lines on a finalized order

State: Failed finished in 234m

PR State: merged

PR Author: Roy Le

PR Author Email:

PR: #1230

Committer: Roy Le

Committer Email: roy.le@viindoo.com

Commit: 1f2724015d34f5595c21baff69c672e8e089fd38

Description:

                                            [FIX] pos_loyalty: keep reward lines on a finalized order

Steps to reproduce:
- Install pos_loyalty + pos_online_payment.
- Configure an automatic discount program (e.g. 1% off the order) and an
  online payment method.
- In the POS, add a customer eligible for the program and a product so
the
  discount reward line is added automatically.
- Pay the order with the online payment method and let the customer pay.

Issue:
The receipt printed right after the online payment is missing the
loyalty
discount line: the total is shown without the discount while the amount
actually paid is the discounted amount, so the ticket looks underpaid.
Re-printing the order later shows the correct total. With a loyalty
program
that also gives points, confirming the order additionally raises:
    ValueError: invalid literal for int() with base 10: 'false'

Cause:
After a successful online payment the order is rebuilt from the data
saved
on the server and selected again. Selecting an order triggers
`_updateRewards`, which calls `_updateRewardLines` to refresh the
applied
rewards. On this rebuilt order the reward lines reference a coupon that
is
no longer in the local cache (its `coupon_id` comes back as `false` for
"current" programs that don't persist a coupon), so `_updateRewardLines`
removes them and cannot re-apply them. The order then displays a wrong
total, and `_postPushOrderResolve` sends that `false` coupon id to
`confirm_coupon_programs`, which fails when casting the key to an int.

The order is already paid and saved: its reward lines are authoritative
and
must not be recomputed.

Fix:
- `_updateRewardLines`: do nothing on a finalized order
(paid/done/invoiced)
  so the rewards saved on the server are kept as-is.
- `_postPushOrderResolve`: skip reward lines that have no coupon, so no
  invalid coupon id is sent to `confirm_coupon_programs`.
                                            

Branch: 17.0

Instance ID: 0

Age:

Up-time:

Subbuilds Name State Detail
Build 385925 At install tests: from account to website_twitter 158m Succeed Log
Build 385926 Post install tests: step install all modules 93m Succeed Log
Build 385927 Post install tests: from account to payment_adyen 139m Failed Log
Build 385928 Post install tests: from payment_alipay to test_viin_approval 159m Succeed Log
Build 385929 Post install tests: from test_viin_mail_route to to_warranty_sale_stock 64m Succeed Log
Build 385930 Post install tests: from to_warranty_stock to viin_features_activate_contacts 64m Succeed Log
Build 385931 Post install tests: from viin_features_activate_freight to viin_project_scrum_helpdesk 29m Succeed Log
Build 385932 Post install tests: from viin_project_timesheet_leave to website_twitter 49m Succeed Log
Create Date Level Message
06/16/2026 12:05:13 INFO
Updated repository Viindoo-tvtmaaddons
06/16/2026 12:05:13 INFO
Updated repository Viindoo-erponline-enterprise
06/16/2026 12:05:13 INFO
Updated repository Viindoo-branding
06/16/2026 12:05:13 INFO
Cloned repository Viindoo-odoo
06/16/2026 16:00:00 ERROR
Subbuild # 385927: odoo.tests.suite: ERROR: setUpClass (odoo.addons.l10n_vn_viin_vat_counterpart.tests.test_l10n_vn_vat_counterpart.TestVatCounterpartVn) Traceback (most recent call last): File "/data/build/rb-1f27240-222212/odoo/tools/cache.py", line 99, in lookup r = d[key] File "<decorator-gen-5>", line 2, in __getitem__ File "/data/build/rb-1f27240-222212/odoo/tools/func.py", line 87, in locked return func(inst, *args, **kwargs) File "/data/build/rb-1f27240-222212/odoo/tools/lru.py", line 34, in __getitem__ a = self.d[obj] KeyError: ('ir.model.data', <function IrModelData._xmlid_lookup at 0x7f97788681f0>, 'l10n_vn_viin.account_account_tag_1711') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/data/build/Viindoo-tvtmaaddons-17.0/l10n_vn_viin_vat_counterpart/tests/test_l10n_vn_vat_counterpart.py", line 14, in setUpClass super().setUpClass(chart_template_ref=chart_template_ref) File "/data/build/rb-1f27240-222212/addons/account/tests/common.py", line 69, in setUpClass cls.company_data_2 = cls.setup_company_data('company_2_data', chart_template=chart_template_ref) File "/data/build/rb-1f27240-222212/addons/account/tests/common.py", line 257, in setup_company_data cls.env['account.chart.template'].try_loading(chart_template, company=company, install_demo=False) File "/data/build/rb-1f27240-222212/addons/account/models/chart_template.py", line 155, in try_loading return self._load(template_code, company, install_demo) File "/data/build/Viindoo-tvtmaaddons-17.0/l10n_vn_viin_hr_payroll_account_overtime/models/account_chart_template.py", line 8, in _load super(AccountChartTemplate, self)._load(template_code, company, install_demo) File "/data/build/Viindoo-tvtmaaddons-17.0/l10n_vn_viin_hr_payroll_account/models/account_chart_template.py", line 8, in _load super(AccountChartTemplate, self)._load(template_code, company, install_demo) File "/data/build/Viindoo-tvtmaaddons-17.0/viin_foreign_trade/models/account_chart_template.py", line 9, in _load res = super()._load(template_code, company, install_demo) File "/data/build/Viindoo-tvtmaaddons-17.0/viin_approval_account/models/account_chart_template.py", line 8, in _load super()._load(template_code=template_code, company=company, install_demo=install_demo) File "/data/build/Viindoo-tvtmaaddons-17.0/l10n_vn_viin_loan_management/models/account_chart_template.py", line 8, in _load super(AccountChartTemplate, self)._load(template_code, company, install_demo) File "/data/build/Viindoo-tvtmaaddons-17.0/l10n_vn_viin_account_auto_transfer/models/chart_template.py", line 9, in _load super()._load(template_code, company, install_demo) File "/data/build/Viindoo-tvtmaaddons-17.0/l10n_vn_viin/models/account_chart_template.py", line 162, in _load super(AccountChartTemplate, template_loader)._load(template_code, company, install_demo) File "/data/build/Viindoo-tvtmaaddons-17.0/viin_account_auto_transfer/models/account_chart_template.py", line 17, in _load return super(AccountChartTemplate, self)._load(template_code, company, install_demo) File "/data/build/Viindoo-tvtmaaddons-17.0/to_vat_counterpart/models/account_chart_template.py", line 11, in _load res = super()._load(template_code, company, install_demo) File "/data/build/Viindoo-tvtmaaddons-17.0/to_loan_management/models/account_chart_template.py", line 16, in _load super(AccountChartTemplate, self)._load(template_code, company, install_demo) File "/data/build/Viindoo-tvtmaaddons-17.0/to_currency_conversion_diff/models/account_chart_template.py", line 9, in _load res = super()._load(template_code, company, install_demo) File "/data/build/rb-1f27240-222212/addons/point_of_sale/models/chart_template.py", line 22, in _load result = super()._load(template_code, company, install_demo) File "/data/build/rb-1f27240-222212/addons/account/models/chart_template.py", line 213, in _load self._load_data(data) File "/data/build/rb-1f27240-222212/addons/account/models/chart_template.py", line 620, in _load_data 'values': deref_values(record_vals, self.env[model]), File "/data/build/rb-1f27240-222212/addons/account/models/chart_template.py", line 541, in deref_values values[fname] = [Command.set([ File "/data/build/rb-1f27240-222212/addons/account/models/chart_template.py", line 542, in <listcomp> self.ref(v).id File "/data/build/Viindoo-erponline-enterprise-17.0/l10n_vn_viin_account_reports/models/account_chart_template.py", line 26, in ref res = self._ref_fallback_for_chart_accounts(xmlid, error, raise_if_not_found=raise_if_not_found) File "/data/build/Viindoo-erponline-enterprise-17.0/l10n_vn_viin_account_reports/models/account_chart_template.py", line 41, in _ref_fallback_for_chart_accounts raise error File "/data/build/Viindoo-erponline-enterprise-17.0/l10n_vn_viin_account_reports/models/account_chart_template.py", line 24, in ref res = super().ref(xmlid, raise_if_not_found=raise_if_not_found) File "/data/build/rb-1f27240-222212/addons/account/models/chart_template.py", line 1081, in ref return self.env.ref(xmlid, raise_if_not_found) File "/data/build/rb-1f27240-222212/odoo/api.py", line 596, in ref res_model, res_id = self['ir.model.data']._xmlid_to_res_model_res_id( File "/data/build/rb-1f27240-222212/odoo/addons/base/models/ir_model.py", line 2215, in _xmlid_to_res_model_res_id return self._xmlid_lookup(xmlid) File "<decorator-gen-43>", line 2, in _xmlid_lookup File "/data/build/rb-1f27240-222212/odoo/tools/cache.py", line 104, in lookup value = d[key] = self.method(*args, **kwargs) File "/data/build/rb-1f27240-222212/odoo/addons/base/models/ir_model.py", line 2208, in _xmlid_lookup raise ValueError('External ID not found in the system: %s' % xmlid) ValueError: External ID not found in the system: l10n_vn_viin.account_account_tag_1711
06/16/2026 16:00:00 ERROR
Subbuild # 385927: odoo.tests.result: 0 failed, 1 error(s) of 2266 tests when loading database 'rb-1f27240-222212-385927'