Skip to content

[19.0][ADD] sale_section_stock_move#4261

Open
santostelmo wants to merge 1 commit intoOCA:19.0from
camptocamp:19.0-add-sale_section_stock_move
Open

[19.0][ADD] sale_section_stock_move#4261
santostelmo wants to merge 1 commit intoOCA:19.0from
camptocamp:19.0-add-sale_section_stock_move

Conversation

@santostelmo
Copy link
Copy Markdown
Contributor

This module propagates sale order section information to stock
operations.

It adds a Sale Section on stock moves from the related sale order line
section, and exposes the section name on stock moves and stock move
lines.

The section information is available in stock move and stock move line
list views, search filters, group by options, and in the Operations tab
of stock pickings.

Depends of #4260

@santostelmo santostelmo changed the title [ADD] sale_section_stock_move [19.0][ADD] sale_section_stock_move Apr 8, 2026
@santostelmo santostelmo force-pushed the 19.0-add-sale_section_stock_move branch from 9b87573 to c507ec5 Compare April 8, 2026 12:24
@rousseldenis rousseldenis added this to the 19.0 milestone Apr 9, 2026
Comment thread sale_section_stock_move/models/stock_move.py Outdated
@santostelmo santostelmo force-pushed the 19.0-add-sale_section_stock_move branch from c507ec5 to e68503d Compare April 9, 2026 07:55
class StockMove(models.Model):
_inherit = "stock.move"

sale_section_id = fields.Many2one(
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.

is this relevant for ALL moves and move lines? 🤔
A change on so line section might have a big perf impact. no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

is this relevant for ALL moves and move lines?

The fields are added on stock.move and stock.move.line, so the columns exist for all records, but they’ll only be filled (non-null) for moves/move lines that come from a sale order line (sale_line_id) and where that sale line has a section (section_id). For other moves (inventory, manufacturing, purchase, etc.) it stays empty.

A change on so line section might have a big perf impact. no?

It can, yes.
Because sale_section_id / sale_section_name are stored related fields, if you change the section on a sale order line, Odoo may need to recompute + write the stored value on all dependent records:

  • all stock.move linked to that sale line (sale_line_id)
  • and then all stock.move.line linked to those moves
    So if someone bulk-updates sections on confirmed orders with lots of moves/move lines, that can trigger a large cascade of writes (and be noticeable on big DBs).
    If section changes are rare, the impact is usually limited.

Another option:
Make sale_section_* non-stored computed/related fields.

  • Pros: changing the section won’t trigger mass writes on moves/move lines.
  • Cons: you generally lose efficient search/group-by on those fields (or it becomes slower because it computes on the fly).

@santostelmo santostelmo force-pushed the 19.0-add-sale_section_stock_move branch from e68503d to f232511 Compare May 7, 2026 07:28
@OCA-git-bot OCA-git-bot added series:19.0 mod:sale_section_stock_move Module sale_section_stock_move labels May 7, 2026
@santostelmo santostelmo requested a review from simahawk May 8, 2026 11:07
@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

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.

6 participants