Skip to content

[16.0] [REF] sale_quotation: Avoid unnecessary ping pong calls - #9

Closed
paradoxxxzero wants to merge 39 commits into
acsone:16.0-refactor-quotations-rest-apifrom
akretion:16.0-fix-refactor-quotations-rest-api
Closed

[16.0] [REF] sale_quotation: Avoid unnecessary ping pong calls#9
paradoxxxzero wants to merge 39 commits into
acsone:16.0-refactor-quotations-rest-apifrom
akretion:16.0-fix-refactor-quotations-rest-api

Conversation

@paradoxxxzero

@paradoxxxzero paradoxxxzero commented Nov 10, 2025

Copy link
Copy Markdown

Following the @sebastienbeau review of shopinvader#1597, here's our proposal for a simplfied workflow/logic.

New sale.order actions are checked on quotation state.

Sale original actions are not, except confirm that has a confirmation popup that is now working.

nicolas-delbovier-acsone and others added 30 commits May 16, 2025 15:50
* Extracts the shop_order_mode of products in a new module
* Enables to choose a combined shop order mode (quotation or direct sale)
* Adds a migration script to translate the products and templates order mode infos from the old to the new fields
…nce API

- put shopinvader_sale_state as a dependency in order to remove sale_cart because we need the field sale.order.shopinvader_state

This commit introduces significant enhancements to the REST API for quotation management, including:

- **Create Method:** Added a new endpoint to create quotations.
- **Line Management Methods:** Implemented dedicated endpoints for adding, deleting, or updating single or multiple lines within a quotation.
- **Update Extension:** Extended the existing update method to support the addition of new lines
…tion" action in the form view of sale.order + refine module description
- Remove typology field from quotation create request
- Implement following logic in the update process:
  -If the line has an id -> update existing line (raise if not found)
  -If the line has no id -> create a new one
  -All existing lines not found in lines should be removed
- Small refactoring to avoid code dup
- Test invalid line ids in unit tests
Deletes an obsolete unit test that was migrated to the `sale_cart_quotation` module.
…ional custom workflow

This commit addresses a critical regression where the standard Odoo sales order confirmation flow was unintentionally broken, making it impossible to directly confirm a newly created SO.

The previous logic implicitly forced a custom quotation process even when not desired. This refactor introduces an explicit opt-in mechanism for the new quotation workflow.

Key changes:
- **Default Typology:** Removed a redundant test in `sale_typology` as the `typology` field's default value is now correctly handled and overridden by `sale_quotation`.
- **Workflow Toggle:** Added a `use_customer_quotation_workflow` boolean field to `sale.order`, allowing users to enable or disable the custom quotation stages.
- **Controlled Confirmation:** When `use_customer_quotation_workflow` is active, a UI wizard now prompts the user to confirm their intent if they attempt to confirm a quotation not yet in the 'waiting_acceptation' state. This preserves the standard Odoo workflow for non-workflow-enabled orders while providing a gentle warning for custom flows.
* add a button to accept the quotation
* add some margin to the workflow text
* Show quotation_state in the title instead of messing with the status bar
Changes `action_confirm_quotation` to `action_accept_quotation`.
Normal quotations are sale.order with an other typology than 'cart'. This allows the use of others values for typology than 'cart' and 'sale'.
Ensures menu are properly working if sale_cart or sale_quoration are installed but not the orher one
Use a switch button to activate / deactivate the user workflow for quotation. All the logic is now driven by the field and we no more need to manipulate the typology
Add methods triggered by the cutomer to manage the requested quotation. Ensures that methods called by customer are allowed according the the quotation state
Adds customer methods used to manage the quotation flow.
Ensures proper http status is returned in case where the called method is not allowed according to the quotation state
The customer can only fill the client ref as rederence. The name is reserved for Odoo
lmignon and others added 7 commits July 23, 2025 12:26
Allows to search on quotation_state and client_order_ref
complete pot files are required to get the translations working. Indeed, when a transation file is loaded by the polib, the entry is marked as obsolete if it's not present into the pot file. obsolete entries are not loaded by odoo
…d upon creation

When a quotation is created via the API client, the assigned salesperson (user_id)
was not automatically added as a follower.

This occurred because the Odoo core mechanism for auto-subscribing the user_id
is only triggered when the 'user_id' value is explicitly present in the create
values dictionary. Since the API relies on Odoo's default value computation
to assign the salesperson, the auto-subscription logic was incorrectly bypassed.

This commit explicitly calls message_subscribe for the assigned user_id.partner_id
during the API creation flow, ensuring the salesperson receives relevant Chatter
notifications as expected.
Comment thread sale_quotation/models/sale_order.py Outdated
Comment thread sale_quotation/models/sale_order.py Outdated
Comment thread sale_quotation/models/sale_order.py Outdated
@paradoxxxzero
paradoxxxzero force-pushed the 16.0-fix-refactor-quotations-rest-api branch 3 times, most recently from 120a825 to f408b88 Compare November 10, 2025 15:55
@paradoxxxzero
paradoxxxzero marked this pull request as ready for review November 10, 2025 16:04
Comment thread sale_quotation/models/sale_order.py Outdated
Comment on lines +200 to +213
return {
"name": _("Confirm Sale Order"),
"type": "ir.actions.act_window",
"res_model": "sale.order.confirm.warning.wizard",
"views": [[False, "form"]],
"target": "new",
"context": {
"default_sale_order_ids": self.ids,
"default_message": _(
"The selected quotation(s) are not in 'Waiting Acceptation' "
"state. Are you sure you want to confirm them?"
),
},
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We should use it the raise RedirectWarning. It will avoid to commit stuff that have been added before

Comment thread sale_quotation/tests/test_quotation.py Outdated
@paradoxxxzero
paradoxxxzero force-pushed the 16.0-fix-refactor-quotations-rest-api branch from f408b88 to e2a5577 Compare May 27, 2026 10:22
@paradoxxxzero
paradoxxxzero requested a review from lmignon May 27, 2026 10:24
Use RedirectWarning to avoid unwanted commit
@sebastienbeau

Copy link
Copy Markdown

@nicolas-delbovier-acsone it should be ready

@nicolas-delbovier-acsone

Copy link
Copy Markdown

Thanks for your contribution! I am going to cherry-pick your simplification commit onto our branch so I can re-run the tests.

Regarding the RedirectWarning approach: using backend exceptions for user confirmations means that when the user hits "Continue", the entire execution path leading up to the warning runs twice.

To avoid this double execution and ensure proper transaction safety, I have refactored the logic to use the native confirm attribute on the view's button. This moves the confirmation popup to the UI side where it belongs, keeping the backend execution clean and efficient.

@nicolas-delbovier-acsone
nicolas-delbovier-acsone force-pushed the 16.0-refactor-quotations-rest-api branch 2 times, most recently from 137ba42 to a70632f Compare May 28, 2026 10:41
@paradoxxxzero

Copy link
Copy Markdown
Author

Included in shopinvader#1597

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.

4 participants