Skip to content

[19.0][IMP] subscription_oca: change customer wizard#1452

Open
alvaro-domatix wants to merge 1 commit into
OCA:19.0from
alvaro-domatix:19.0-imp-subscription_oca-change-customer
Open

[19.0][IMP] subscription_oca: change customer wizard#1452
alvaro-domatix wants to merge 1 commit into
OCA:19.0from
alvaro-domatix:19.0-imp-subscription_oca-change-customer

Conversation

@alvaro-domatix

Copy link
Copy Markdown

Adds a wizard to change the customer of one or more subscriptions from the list/form action menu.

It refuses closed subscriptions, skips records whose customer does not actually change, optionally updates the pricelist and the recomputed fiscal position in the same write, and posts a note in the chatter of each subscription. Invoices already issued keep their original partner; only the subscription and its future invoices and orders are affected.

The action is restricted to sale managers, since changing the customer of a running contract is a sensitive operation.

@OCA-git-bot OCA-git-bot added series:19.0 mod:subscription_oca Module subscription_oca labels Jun 9, 2026
@alvaro-domatix alvaro-domatix force-pushed the 19.0-imp-subscription_oca-change-customer branch from 61738ff to 42373eb Compare June 9, 2026 20:07

@jorgeglez1990 jorgeglez1990 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A functional review has been carried out, and it was detected that when changing the customer to another one with a specific pricelist assigned, the line price is updated correctly, but the invoice total is not recalculated or updated.

It would be preferable to develop this functionality in a separate addon that inherits from the corresponding module, in order to avoid modifying the base module.

Image

Add a transient wizard to change the customer on one or more
subscriptions from the list-view action menu.

* `sale.subscription.change.partner.wizard` (transient). The affected
  subscriptions default from `active_ids`, so the same wizard serves
  single-record and bulk operations.
* `action_apply` refuses closed subscriptions, skips records whose
  customer does not actually change, writes the new partner and
  (optionally) the customer's pricelist and the recomputed fiscal
  position in a single write, and posts an audit line on each
  subscription's chatter.
* The fiscal position is resolved through
  `sale.subscription._get_fiscal_position_from_partner`, a plain method
  reused by the existing onchange, instead of relying on onchange side
  effects for persistence.

The change applies to the subscription and its future invoices and
orders; invoices already issued are not reassigned. The action is bound
to `sale.subscription` (list, form) and its ACL is granted to
`sales_team.group_sale_manager` only, since changing the customer of a
contract is a sensitive operation.
@alvaro-domatix alvaro-domatix force-pushed the 19.0-imp-subscription_oca-change-customer branch from 145a216 to c8764aa Compare June 25, 2026 18:25
@alvaro-domatix

Copy link
Copy Markdown
Author

Hi @jorgeglez1990, thanks for catching this. I investigated and the root cause is in the core, not in the wizard itself: sale.subscription._compute_total only depended on the list of lines (sale_subscription_line_ids) and not on the lines' price_subtotal. Since recurring_total/amount_total are stored, any change to an existing line's price (a pricelist change, a manual edit, a discount update) recomputed the line subtotals but did not refresh the subscription totals. The change-customer wizard exposes it because it reassigns the pricelist on a subscription whose lines already exist.

The fix is in #1474_compute_total now depends on price_subtotal/amount_tax_line_amount, with a regression test. Once it lands, the wizard's totals will stay correct.

On the separate-addon point: the wizard is a small, self-contained extension of the base, and the bug above turned out to be pre-existing in the core rather than introduced by it; I'd lean towards keeping it here, but happy to split it out if you still see value in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants