Skip to content

[16.0][ADD] sale_order_confirm_partial: add module#2958

Closed
dmitriypaulov wants to merge 1 commit intoOCA:16.0from
cetmix:16.0-t3222-sale_order_confirm_partial-add_module
Closed

[16.0][ADD] sale_order_confirm_partial: add module#2958
dmitriypaulov wants to merge 1 commit intoOCA:16.0from
cetmix:16.0-t3222-sale_order_confirm_partial-add_module

Conversation

@dmitriypaulov
Copy link
Copy Markdown

@dmitriypaulov dmitriypaulov commented Feb 15, 2024

This module allows to select which sale order lines you would like to confirm. It also can create a new quotation in the "Cancel" state with all the unconfirmed lines from the original quotation in case you need to keep that information.

@dmitriypaulov dmitriypaulov marked this pull request as draft February 15, 2024 17:22
@dmitriypaulov dmitriypaulov force-pushed the 16.0-t3222-sale_order_confirm_partial-add_module branch 5 times, most recently from 4b6cb4e to bd26a1e Compare February 15, 2024 18:18
)

@api.onchange("mode")
def _onchange_mode(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we use compute with readonly=False instead of onchange here?

@dmitriypaulov dmitriypaulov force-pushed the 16.0-t3222-sale_order_confirm_partial-add_module branch 8 times, most recently from 1086848 to c449bef Compare February 22, 2024 02:04
Copy link
Copy Markdown
Member

@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

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

Check the comments and add tests pls.

unconfirmed_order = self.copy(
{
"name": self.name + unconfirmed_suffix,
"order_line": False,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why not to set "cancel" state directly here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Because in the loop below I'm changing order lines of this order, but Odoo restricts such changes for orders in Cancel state

- confirmed_line.confirmed_qty,
}
)
unconfirmed_order.state = "cancel"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Check the comment at L84

@dmitriypaulov dmitriypaulov force-pushed the 16.0-t3222-sale_order_confirm_partial-add_module branch from 0c577d5 to c9c557a Compare February 26, 2024 14:38
Copy link
Copy Markdown

@angelinaanaki angelinaanaki left a comment

Choose a reason for hiding this comment

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

Code LGTM

Copy link
Copy Markdown
Member

@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

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

LGTM

@dmitriypaulov dmitriypaulov force-pushed the 16.0-t3222-sale_order_confirm_partial-add_module branch from c9c557a to 0368b40 Compare March 1, 2024 11:47
@dmitriypaulov dmitriypaulov marked this pull request as ready for review March 1, 2024 11:48
# Check original order lines quantities
# (they should stay the same)
self.assertEqual(
self.sale_order.order_line[0].product_uom_qty,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is what I was talking about in the previous comment. You need to use direct reference. Eg

self.so_line_1.product_uom_qty,

Copy link
Copy Markdown
Member

@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

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

LGTM

@dmitriypaulov dmitriypaulov force-pushed the 16.0-t3222-sale_order_confirm_partial-add_module branch from bc7643b to 654e1ce Compare March 5, 2024 11:30
@rousseldenis rousseldenis added this to the 16.0 milestone Jun 17, 2024
@rousseldenis
Copy link
Copy Markdown
Contributor

@dmitriypaulov What's the status of this ?

@ivs-cetmix
Copy link
Copy Markdown
Member

Hi

@dmitriypaulov What's the status of this ?

Hi @rousseldenis we are already using this module. However would appreciate additional code review.

Copy link
Copy Markdown
Member

@Deriman-Alonso Deriman-Alonso left a comment

Choose a reason for hiding this comment

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

LGTM 👍.

@ivs-cetmix
Copy link
Copy Markdown
Member

@dmitriypaulov What's the status of this ?

Hi @rousseldenis, could we have this checked and merged?

@ivs-cetmix
Copy link
Copy Markdown
Member

Hey @OCA/crm-sales-marketing-maintainers I know that's summer holiday season and probably you are enjoying your drinks is some beach bars 😄
However would be great if someone could have a look at this in between of two "margaritas" 🍹

@Aldeigja Aldeigja force-pushed the 16.0-t3222-sale_order_confirm_partial-add_module branch from 654e1ce to 705517c Compare August 23, 2024 08:05
@ivs-cetmix
Copy link
Copy Markdown
Member

Hey @OCA/crm-sales-marketing-maintainers I know that's summer holiday season and probably you are enjoying your drinks is some beach bars 😄 However would be great if someone could have a look at this in between of two "margaritas" 🍹

Hey @OCA/crm-sales-marketing-maintainers and @rousseldenis
Any chances for this to be merged?

@Aldeigja Aldeigja force-pushed the 16.0-t3222-sale_order_confirm_partial-add_module branch from 705517c to efb3c71 Compare February 24, 2025 10:28
@rousseldenis
Copy link
Copy Markdown
Contributor

@dmitriypaulov @ivs-cetmix CI is red. Could you rebase ?

@ivs-cetmix ivs-cetmix force-pushed the 16.0-t3222-sale_order_confirm_partial-add_module branch 2 times, most recently from 9447fbe to 7ac09ab Compare November 23, 2025 20:32
@ivs-cetmix
Copy link
Copy Markdown
Member

Hi @rousseldenis , PR is rebased. Let me know what should be done next.

@rousseldenis
Copy link
Copy Markdown
Contributor

@dmitriypaulov @ivs-cetmix you should fix tests

@ivs-cetmix ivs-cetmix force-pushed the 16.0-t3222-sale_order_confirm_partial-add_module branch from 7ac09ab to c176a52 Compare February 17, 2026 19:57
[ADD] sale_order_confirm_partial: add tests

[REF] sale_order_confirm_partial: safer approach to test so lines
@ivs-cetmix ivs-cetmix force-pushed the 16.0-t3222-sale_order_confirm_partial-add_module branch from c176a52 to 99a413a Compare February 17, 2026 19:57
Copy link
Copy Markdown
Member

@mmequignon mmequignon left a comment

Choose a reason for hiding this comment

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

What about sale_order_split_strategy (available in 18.0) ?

@ivs-cetmix
Copy link
Copy Markdown
Member

What about sale_order_split_strategy (available in 18.0) ?

That's absolutely different module. This one is user-focused: "I have an order, I want to confirm it right now, but only Item A and Item B".
The sale_order_split_strategy is about "Let's define some rules and apply them later".

P.S. this module was initially developed for a project that ... and it's gone... 😆 So if you would like to have this merge would appreciate your assistance with tests as it looks like they need to be addressed still.

@mmequignon
Copy link
Copy Markdown
Member

That's absolutely different module. This one is user-focused: "I have an order, I want to confirm it right now, but only Item A and Item B". The sale_order_split_strategy is about "Let's define some rules and apply them later".

P.S. this module was initially developed for a project that ... and it's gone... 😆 So if you would like to have this merge would appreciate your assistance with tests as it looks like they need to be addressed still.

I would rather use the sale_order_split_strategy module, add a new field to_split on sale_order_line, and have a rule extracting lines with to_split == True.

I honestly would avoid having 2 modules doing "mostly" the same thing but with a slight difference.

@ivs-cetmix
Copy link
Copy Markdown
Member

I would rather use the sale_order_split_strategy module, add a new field to_split on sale_order_line, and have a rule extracting lines with to_split == True.

I honestly would avoid having 2 modules doing "mostly" the same thing but with a slight difference.

I got your point, however they are absolutely different modules designed for different things. Yes, they both split quotations, but this is the only thing they have in common. I would recommend you to open the documentation for the both modules and check it.
Adding a rule may look good from the developer perspective, but it's a mess from the user's one. User's don't want to mess with technical things. They want it to work simple and straightforward.
Let's say a salesperson is in a call with a client discussing a quotation. The negotiations go so-so, but finally the client says "Ok, I will by Item 2 and 3 pcs of Item 7". How you suppose a salesperson to do this instantly with the sale_order_split_strategy ? "Hey, wait for a while, let me create a new strategy for your order?" 😄

@mmequignon
Copy link
Copy Markdown
Member

mmequignon commented Feb 18, 2026

I would rather use the sale_order_split_strategy module, add a new field to_split on sale_order_line, and have a rule extracting lines with to_split == True.
I honestly would avoid having 2 modules doing "mostly" the same thing but with a slight difference.

I got your point, however they are absolutely different modules designed for different things. Yes, they both split quotations, but this is the only thing they have in common. I would recommend you to open the documentation for the both modules and check it. Adding a rule may look good from the developer perspective, but it's a mess from the user's one. User's don't want to mess with technical things. They want it to work simple and straightforward. Let's say a salesperson is in a call with a client discussing a quotation. The negotiations go so-so, but finally the client says "Ok, I will by Item 2 and 3 pcs of Item 7". How you suppose a salesperson to do this instantly with the sale_order_split_strategy ? "Hey, wait for a while, let me create a new strategy for your order?" 😄

You are misunderstanding my point I think.
We can create a module based on sale_order_split_strategy.
The module adds the rule and a boolean field on sale_order_line, done.
After that the user just has to toggle lines to be confirmed, which is exactly what this module does.

I would rather backport sale_order_split_strategy and eventually create a module for your specific need.

@ivs-cetmix
Copy link
Copy Markdown
Member

You are misunderstanding my point I think. We can create a module based on sale_order_split_strategy. The module adds the rule and a boolean field on sale_order_line, done. After that the user just has to toggle lines to be confirmed, which is exactly what this module does.

I would rather backport sale_order_split_strategy and eventually create a module for your specific need.

I see, got your point now. Yes, this might be reasonable. In this case I would prefer to abandon this PR but leave it in case someone would like to implement this later. Probably it makes no sense to keep it for 16.0 as the main focus shifted to 18.0 already.

Copy link
Copy Markdown

@alexey-pelykh alexey-pelykh left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. I looked through the code and I tend to agree with @mmequignon's suggestion -- building on top of sale_order_split_strategy (with a backport to 16.0 if needed) would be a cleaner path and avoid maintaining two modules with overlapping scope.

Since @ivs-cetmix also acknowledged this direction makes sense, it might be worth closing this PR in favor of that approach.

That said, a few code-level notes in case anyone picks this up or adapts it later:

  1. action_confirm breaks multi-record calls. The override uses self.id (singular) to set default_sale_order_id on the wizard, but stock action_confirm supports multi-record. When partial confirmation is enabled, calling action_confirm() on a recordset of multiple orders would silently use only the last order's id. Should at minimum add self.ensure_one() or loop explicitly.

  2. Tests reference fields that don't exist on the model. In test_confirmation_with_save_unconfirmed_selected, the assertion filters unconfirmed_so.order_line using lambda x: x.so_line_id == self.so_line_1 -- but sale.order.line has no so_line_id field (that's on the wizard line model). This is likely why CI is red.

  3. attrs syntax is deprecated in Odoo 16+. The views use attrs="{'invisible': [...]}" which still works in 16.0 but newer OCA linting may flag it. Minor point for a 16.0 target.

  4. String formatting with % in translatable strings. The message_post calls use _("...") % {...} -- while this works, OCA guidelines generally prefer _("... %(name)s ...") % {...} which is already used here, so that part is fine.

@rousseldenis
Copy link
Copy Markdown
Contributor

@ivs-cetmix Could we close ?

@ivs-cetmix
Copy link
Copy Markdown
Member

@rousseldenis yes, thank you!

@ivs-cetmix ivs-cetmix closed this Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants