-
Notifications
You must be signed in to change notification settings - Fork 3
shopinvader_api_delivery_carrier: hide delivery line in cart #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 16.0
Are you sure you want to change the base?
shopinvader_api_delivery_carrier: hide delivery line in cart #11
Conversation
Can you elaborate the use case? |
@sebastienbeau I don't really see why we should hide lines from a SO. You always have the 'name' field, which gives information describing what the line represents (you can have lines that are notes, sections, delivery charges, ....). Even if the line refers to a technical product that may not be available in ES, this should not matter. The product life cycle will mean that a product purchased in the past will no longer be present in ES, and this should not block the display of an order in the UI. Taking this a step further, the fact that the product identifier may or may not be available to the consumer of the API should not be a factor in this discussion, since we are dealing here with the API and not with its use by a website. But maybe I miss something... |
Hi @sbidoul @sbidoul sorry for the delay The idea it to give a better experience for the front-end developer (like we had in version 14 see: https://github.com/shopinvader/odoo-shopinvader/blob/0b031e87c4a64e7f013598e2f8c76ac206c126cd/shopinvader_delivery_carrier/services/abstract_sale.py#L48). In the schema of the cart / sale the delivery price is accessible with special key see here: https://github.com/shopinvader/odoo-shopinvader-carrier/blob/d681c1a788d886a0da5e37c8a73cea2cf05c6b98/shopinvader_api_delivery_carrier/schemas/amount.py Before this PR we have a duplicated information
In a front end point of view. It make no sense to have the delivery as a product and they always have to remove it (If the delivery cost exist in a line in odoo is only because of the implementation, so It should not design our API). Note: I choose to add a computed field so It's easier to reuse this computed field when trying to read the sale.line directly using this API : shopinvader/odoo-shopinvader#1508 without creating too many glue module. Thanks for your feedback |
I sort of see your point, but
How does the front end dev filter today? In a project I see this: Indeed it does not seem very easy to detect shipping and reward lines. Would a cc/ @marielejeune @qgroulard who may have an opinion on this too. |
Indeed from the schema it is impossible to detect reward and delivery lines for now. |
After thinking twice I agree that the naming is not really good and the architecture also. In anycase I really think that filtering should not be done on the frontend. Thibault was totally crazy when he realize that we return duplicated information in the API (api should be as simple as possible, any time we introduce something not natural, frontend will need to spend time for understand the "weird" behaviour, we should try to give the best experience) I see an other possibility Filtering with a domainIn shopinvader_schema_sale/schemas/sale.py
Then in this module we can extend
And in this PR (that add an endpoint for exposing directly "sale.order.line") : https://github.com/shopinvader/odoo-shopinvader/pull/1508/files We can extend the domain to include this technical domain : https://github.com/shopinvader/odoo-shopinvader/pull/1508/files#diff-2dd5f80d9018355d48ebc8580045cc8e6d85f12ef8d81842f08492892a1a7ee0R68
Note:
What do you think ? |
And what are the drawbakcs of @marielejeune's proposal in #11 (comment). |
Maybe I didn't understand what @marielejeune have done exactly. I think we should do it by default in this module (if not we always have to hack the custom) |
Yes I agree we should do something by default. But I mean:
would that be simple enough for the frontend dev? |
I do not think that exposing the field "is_reward_line" and "is_delivery" is enough, it's better to filter this lines by default. The issue is that right now in the schema there is not hook to filter line based on this boolean |
Note I have try to have only "one" place where we filter this line. And simple also inherit the "def _get_domain_adapter(self):" to filter the unwanted line when we expose the sale.order.line directly |
Hide delivery line in cart
Depends on