Skip to content

FIX product price.php: preserve default_vat_code and tva_npr when aut…#38034

Open
ATM-NicolasV wants to merge 1 commit intoDolibarr:23.0from
ATM-Consulting:23.0_fix_default_vat_code_wiped_on_price_tab_first_display
Open

FIX product price.php: preserve default_vat_code and tva_npr when aut…#38034
ATM-NicolasV wants to merge 1 commit intoDolibarr:23.0from
ATM-Consulting:23.0_fix_default_vat_code_wiped_on_price_tab_first_display

Conversation

@ATM-NicolasV
Copy link
Copy Markdown
Contributor

@ATM-NicolasV ATM-NicolasV commented Apr 28, 2026

FIX

preserve default_vat_code and tva_npr when auto-creating initial product_price row

When a product has no row in llx_product_price (typical for products imported in bulk where only llx_product was populated), price.php auto-creates an initial history line on first display of the price tab (branch starting at "We must have at least one initial line").

The two updatePrice() calls in this branch omitted parameter 11 ($newdefaultvatcode) which defaults to ''. In Product::updatePrice() the SQL then writes default_vat_code = NULL in BOTH llx_product and the new llx_product_price row, silently wiping a correctly-stored VAT code on every first display.

Symptom: "ErrorBadValueForParamNotAString" rendered next to selling price/min selling price (because $langs->trans($object->price_base_type) is called with NULL when the row is freshly created with empty fields), and default_vat_code persistently reset to NULL until the user manually re-saves through the form.

Fix: forward $object->default_vat_code (and $object->tva_npr for the non-multiprice branch) to updatePrice() so the auto-init preserves the product's VAT configuration.

Instructions

This is a template to help you make good pull requests. You may use Github Markdown syntax to format your issue report.
Please:

  • only keep the "FIX", "CLOSE", "NEW", "UIUX", PERF" or "QUAL" section (use uppercase to have the PR appears into the ChangeLog, lowercase will not appears)
  • follow the project contributing guidelines
  • in particular, in case of a bugfix, please check that you are targetting the branch corresponding to the oldest version in which the bug occurs
  • replace the bracket enclosed texts with meaningful information

…o-creating initial product_price row

When a product has no row in llx_product_price (typical for products
imported in bulk where only llx_product was populated), price.php
auto-creates an initial history line on first display of the price tab
(branch starting at "We must have at least one initial line").

The two updatePrice() calls in this branch omitted parameter 11
(\$newdefaultvatcode) which defaults to ''. In Product::updatePrice()
the SQL then writes default_vat_code = NULL in BOTH llx_product and
the new llx_product_price row, silently wiping a correctly-stored VAT
code on every first display.

Symptom: "ErrorBadValueForParamNotAString" rendered next to selling
price/min selling price (because \$langs->trans(\$object->price_base_type)
is called with NULL when the row is freshly created with empty fields),
and default_vat_code persistently reset to NULL until the user manually
re-saves through the form.

Fix: forward \$object->default_vat_code (and \$object->tva_npr for the
non-multiprice branch) to updatePrice() so the auto-init preserves the
product's VAT configuration.
@ATM-NicolasV ATM-NicolasV requested a review from eldy April 28, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant