Skip to content

[18.0][FIX] rma_sale_lot: Add domain to the lot_id field so that only the appropriate lots can be selected#554

Open
victoralmau wants to merge 1 commit into
OCA:18.0from
Tecnativa:18.0-fix-rma_sale_lot-TT61559
Open

[18.0][FIX] rma_sale_lot: Add domain to the lot_id field so that only the appropriate lots can be selected#554
victoralmau wants to merge 1 commit into
OCA:18.0from
Tecnativa:18.0-fix-rma_sale_lot-TT61559

Conversation

@victoralmau

@victoralmau victoralmau commented Mar 18, 2026

Copy link
Copy Markdown
Member

Add domain to the lot_id field so that only the appropriate lots can be selected

Please @pedrobaeza and @carlos-lopez-tecnativa can you review it?

@Tecnativa TT61559

@pedrobaeza pedrobaeza added this to the 18.0 milestone Mar 18, 2026

@pedrobaeza pedrobaeza left a comment

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.

Not sure if the goal is to restrict it so much. @sbejaoui do you see any problem?

Comment thread rma_sale_lot/wizards/sale_order_line_rma_wizard.py Outdated
@victoralmau victoralmau force-pushed the 18.0-fix-rma_sale_lot-TT61559 branch from 170118a to 5e7a027 Compare March 18, 2026 15:12
Comment on lines +20 to +24
smls = rec.move_id.move_line_ids.filtered(
lambda x: x.state == "done" and x.lot_id
)
domain = [("id", "in", smls.lot_id.ids)]
rec.lot_id_domain = domain

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I agree with adding a domain, because before this commit, any lot could be selected, even lots that belong to other products, which is an error.
But I also think this domain can be too restrictive; I’m not sure, so I’ll wait for more opinions in this case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In the context of the RMA creation wizard from a sales order, in my opinion, you should only be able to select the lots that have been used and not others, don't you think?

@sbejaoui

Copy link
Copy Markdown
Contributor

When opening the wizard, the return lines are automatically populated based on the delivery information, so the lot is already preselected

In our case, users rely on this mechanism to manage customer returns and rarely modify the proposed values

But, if a user does change the suggested lot, it is likely for a good reason, and he knows what he is doing, in this context, applying a restrictive domain could be counterproductive

A domain would be more relevant if the lot were not prefilled by the system, but that is not the case here

If there is still a need to control this field for specific users, a better approach would be to make it read-only for a particular user group so they only change the returned qty by lot

@victoralmau

Copy link
Copy Markdown
Member Author

In my opinion, even though it doesn't happen often because it's self-selecting, allowing users to select a lot that hasn't been used is a mistake (right now, lots aren't even filtered by product).

@victoralmau victoralmau force-pushed the 18.0-fix-rma_sale_lot-TT61559 branch from 0ceca50 to f17649e Compare March 26, 2026 07:38
@victoralmau

Copy link
Copy Markdown
Member Author

When opening the wizard, the return lines are automatically populated based on the delivery information, so the lot is already preselected

In our case, users rely on this mechanism to manage customer returns and rarely modify the proposed values

But, if a user does change the suggested lot, it is likely for a good reason, and he knows what he is doing, in this context, applying a restrictive domain could be counterproductive

A domain would be more relevant if the lot were not prefilled by the system, but that is not the case here

If there is still a need to control this field for specific users, a better approach would be to make it read-only for a particular user group so they only change the returned qty by lot

Although the field is automatically populated, it is currently possible to modify that data; this change is intended to ensure consistency and prevent users from selecting a lot that was not used in related stock move.

In my opinion, I don't think making the field read-only in some cases will solve the problem—it simply won't allow certain users to do so, while others can. For that reason, this change is intended to resolve any potential data inconsistencies (even if they occur by mistake).

@victoralmau victoralmau force-pushed the 18.0-fix-rma_sale_lot-TT61559 branch from f17649e to 0d938f8 Compare June 16, 2026 12:25
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.

5 participants