Skip to content

Commit

Permalink
[14.0][FIX] purchase_location_by_line : Too many receipts are created O…
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarcot authored and FernandoRomera committed Dec 19, 2022
1 parent 00794f7 commit 6d61eb2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion purchase_delivery_split_date/models/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@ def _first_picking_copy_vals(self, key, lines):
vals["scheduled_date"] = key_element["date_planned"]
return vals

def _get_sorted_keys(self, line):
"""Return a tuple of keys to use in order to sort the order lines.
This method is designed for extensibility, so that other modules can
add additional keys or replace them by others."""
return (line.date_planned,)

def _create_stock_moves(self, picking):
"""Group the receptions in one picking per group key"""
moves = self.env["stock.move"]
# Group the order lines by group key
order_lines = sorted(
self.filtered(lambda l: not l.display_type), key=lambda l: l.date_planned
self.filtered(lambda l: not l.display_type),
key=lambda l: self._get_sorted_keys(l),
)
date_groups = groupby(
order_lines, lambda l: self._get_group_keys(l.order_id, l, picking=picking)
Expand Down

0 comments on commit 6d61eb2

Please sign in to comment.