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 intoOCA: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 intoOCA:18.0from
Tecnativa:18.0-fix-rma_sale_lot-TT61559

Conversation

@victoralmau
Copy link
Member

@victoralmau victoralmau commented Mar 18, 2026

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
Copy link
Member

@pedrobaeza pedrobaeza left a comment

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?

@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

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
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
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
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
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