Skip to content

[16.0] refactor quotations rest api#1597

Open
nicolas-delbovier-acsone wants to merge 43 commits into
shopinvader:16.0from
acsone:16.0-refactor-quotations-rest-api
Open

[16.0] refactor quotations rest api#1597
nicolas-delbovier-acsone wants to merge 43 commits into
shopinvader:16.0from
acsone:16.0-refactor-quotations-rest-api

Conversation

@nicolas-delbovier-acsone

Copy link
Copy Markdown

This PR introduces several refactorings to improve module isolation and extend the Shopinvader API:

  1. sale_typology module creation: Isolates the sale order typology logic.
  2. sale_quotation extension: Updates sale_quotation to depend on the new sale_typology module.
  3. sale_cart_quotation module creation: Decouples sale_quotation from sale_cart.
  4. shopinvader_api_quotation enhancement: Enables line creation, update, and deletion within the quotation API.
  5. shopinvader_api_cart_quotation module extraction: Moves the cart-to-quotation transformation logic from shopinvader_api_quotation to its own dedicated module.

@nicolas-delbovier-acsone nicolas-delbovier-acsone changed the title 16.0 refactor quotations rest api [16.0] refactor quotations rest api May 21, 2025
Comment thread sale_cart/models/sale_order.py Outdated
Comment thread sale_cart_quotation/readme/DESCRIPTION.rst Outdated
Comment thread sale_cart_quotation/views/sale_order.xml Outdated
Comment thread sale_quotation/models/sale_order.py Outdated
Comment thread shopinvader_api_quotation/__manifest__.py
Comment thread shopinvader_api_quotation/dependencies.py Outdated
Comment thread shopinvader_api_quotation/dependencies.py Outdated
Comment thread shopinvader_api_quotation/schemas/sale.py Outdated
@sebastienbeau sebastienbeau added this to the 16.0 milestone Jun 2, 2025
@nicolas-delbovier-acsone nicolas-delbovier-acsone force-pushed the 16.0-refactor-quotations-rest-api branch from e676a2c to 6876549 Compare June 16, 2025 06:26
@nicolas-delbovier-acsone

Copy link
Copy Markdown
Author

The last force push aimed at rebasing this PR to #1594.

@nicolas-delbovier-acsone nicolas-delbovier-acsone force-pushed the 16.0-refactor-quotations-rest-api branch from 71c7fab to b4e5b7b Compare July 9, 2025 12:48
@lmignon lmignon marked this pull request as ready for review July 14, 2025 08:39
@lmignon lmignon force-pushed the 16.0-refactor-quotations-rest-api branch from c7a879b to 816d1c6 Compare July 16, 2025 10:20
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
Comment thread sale_quotation/models/sale_order.py Outdated
@lmignon

lmignon commented Sep 1, 2025

Copy link
Copy Markdown
Collaborator

@paradoxxxzero fixed

@sebastienbeau sebastienbeau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the refactor ! Quotation flow will be more powerfull !

)


def InvalidQuotationStateErrorWrapper(func):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting code. Creating a specific error so we can catch it and return a clean http error code is smart.

In long term, maybe we should be able to extend the "convert_exception_to_status_body"
https://github.com/OCA/rest-framework/blob/34c06aab48512b6d7bda8ec797c45ae219a2fc59/fastapi/error_handlers.py#L20 so we can just extend this and it will raise the right http error without needed a wrapper.

The issue with the wrapper is when an other endpoint do an action and you didn't have set the decoration (because you didn't expect this case) you will not have the right http error.

Note a blocking point, it's just a comment to share the idea. If you think it's an interesting one we can to a PR in fastapi to implement it.

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
Comment on lines +181 to +183
return self.with_context(
bypass_customer_quotation=True,
).action_confirm()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change with the previous behavior.
Indeed before this change an accepted quotation was staying in draft (as maybe we wait for extra action like the payment)

The two customer we have, for now make this difference, they want to know that the customer have accepted the quotation, but they wait for the payment to confirm the sale order.

Maybe we can add a general configuration option ? So we can activate or not this behavior.

Comment thread sale_quotation/views/sale_view.xml
Comment thread sale_quotation/models/sale_order.py Outdated
@github-actions

Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

* 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
lmignon and others added 20 commits May 28, 2026 11:42
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
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.
@nicolas-delbovier-acsone nicolas-delbovier-acsone force-pushed the 16.0-refactor-quotations-rest-api branch from 65e34cb to 137ba42 Compare May 28, 2026 09:57
@nicolas-delbovier-acsone

Copy link
Copy Markdown
Author

Can anyone allow the tests to run on this PR?

@nicolas-delbovier-acsone nicolas-delbovier-acsone force-pushed the 16.0-refactor-quotations-rest-api branch from 137ba42 to a70632f Compare May 28, 2026 10:41
…TTP test standards

Fix a series of 422 (Unprocessable Entity) test failures caused by an upstream
upgrade to Starlette/FastAPI.
…ptance

Fix an AccessError on `procurement.group` when a storefront user accepts
a quotation and `sale_stock` is installed.
@nicolas-delbovier-acsone nicolas-delbovier-acsone force-pushed the 16.0-refactor-quotations-rest-api branch from a70632f to 7c5a35b Compare May 29, 2026 09:50
@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.39130% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.34%. Comparing base (fd34c42) to head (7c5a35b).
⚠️ Report is 5 commits behind head on 16.0.

Files with missing lines Patch % Lines
shopinvader_api_quotation/dependencies.py 93.43% 5 Missing and 4 partials ⚠️
sale_quotation/models/sale_order.py 96.29% 1 Missing and 2 partials ⚠️
...vader_product_order_mode/models/product_product.py 82.35% 1 Missing and 2 partials ⚠️
sale_cart_quotation/models/sale_order.py 80.00% 1 Missing and 1 partial ⚠️
shopinvader_api_quotation/routers/quotation.py 96.49% 2 Missing ⚠️
shopinvader_api_quotation/schemas/quotation.py 95.83% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             16.0    #1597      +/-   ##
==========================================
+ Coverage   95.09%   95.34%   +0.24%     
==========================================
  Files         494      519      +25     
  Lines       10168    10862     +694     
  Branches      513      544      +31     
==========================================
+ Hits         9669    10356     +687     
- Misses        354      355       +1     
- Partials      145      151       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot removed the stale label May 31, 2026
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.

4 participants