Skip to content

Commit 9b3874d

Browse files
committed
[FIX] delivery_auto_refresh: don't try to create lines over a new id
Some other modules could trigger the autorefresh even when the order record isn't in the db, and making the line creation fail. We only need it when the record is saved. TT55206
1 parent 3c2caf7 commit 9b3874d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

delivery_auto_refresh/models/sale_order.py

+6
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ def _update_delivery_line(self, delivery_line, price_unit):
121121
if new_vals:
122122
delivery_line.write(new_vals)
123123

124+
def _create_delivery_line(self, carrier, price_unit):
125+
# If the order isn't stored in the db the line creation is going to fail
126+
if not self._origin:
127+
return self.env["sale.order.line"]
128+
return super()._create_delivery_line(carrier, price_unit)
129+
124130
def _auto_refresh_delivery(self):
125131
self.ensure_one()
126132
if (

0 commit comments

Comments
 (0)