Revision 492c85c2
Von Moritz Bunkus vor fast 9 Jahren hinzugefügt
SL/DB/DeliveryOrder.pm | ||
---|---|---|
130 | 130 |
|
131 | 131 |
# Custom shipto addresses (the ones specific to the sales/purchase |
132 | 132 |
# record and not to the customer/vendor) are only linked from |
133 |
# shipto -> delivery_orders. Meaning delivery_orders.shipto_id |
|
134 |
# will not be filled in that case. Therefore we have to return the |
|
135 |
# new shipto object as a separate object so that the caller can |
|
136 |
# save it, too. |
|
137 |
my $custom_shipto; |
|
133 |
# shipto → delivery_orders. Meaning delivery_orders.shipto_id |
|
134 |
# will not be filled in that case. |
|
138 | 135 |
if (!$source->shipto_id && $source->id) { |
139 |
$custom_shipto = $source->custom_shipto->clone($class) if $source->can('custom_shipto') && $source->custom_shipto;
|
|
136 |
$args{custom_shipto} = $source->custom_shipto->clone($class) if $source->can('custom_shipto') && $source->custom_shipto;
|
|
140 | 137 |
|
141 | 138 |
} else { |
142 | 139 |
$args{shipto_id} = $source->shipto_id; |
... | ... | |
172 | 169 |
|
173 | 170 |
$delivery_order->items(\@items); |
174 | 171 |
|
175 |
return ($delivery_order, $custom_shipto);
|
|
172 |
return $delivery_order;
|
|
176 | 173 |
} |
177 | 174 |
|
178 | 175 |
sub customervendor { |
... | ... | |
258 | 255 |
The conversion copies order items into delivery order items. Dates are copied |
259 | 256 |
as appropriate, e.g. the C<transdate> field will be set to the current date. |
260 | 257 |
|
261 |
Returns one or two objects depending on the context. In list context |
|
262 |
the new delivery order instance and a shipto instance will be |
|
263 |
returned. In scalar instance only the delivery order instance is |
|
264 |
returned. |
|
265 |
|
|
266 |
Custom shipto addresses (the ones specific to the sales/purchase |
|
267 |
record and not to the customer/vendor) are only linked from C<shipto> |
|
268 |
to C<delivery_orders>. Meaning C<delivery_orders.shipto_id> will not |
|
269 |
be filled in that case. That's why a separate shipto object is created |
|
270 |
and returned. |
|
271 |
|
|
272 |
The objects returned are not saved. |
|
258 |
Returns the new delivery order instance. The object returned is not |
|
259 |
saved. |
|
273 | 260 |
|
274 | 261 |
C<%params> can include the following options: |
275 | 262 |
|
Auch abrufbar als: Unified diff
DeliveryOrder->new_from: kein $custom_shipto-Objekt zurückgeben
Falls das Quellobjekt eine individuelle Lieferadresse besaß, wurden bei
new_from() zwei Objekte zurückgegeben: das neue Lieferscheinobjekt und
ein Clone der individuellen Lieferadresse. Diese waren nicht verknüpft.
Der Aufrufer musste daher zuerst das Lieferscheinobjekt speichern,
dessen ID beim gecloneten Lieferadressenobjekt hinterlegen und das
anschließend speichern.
Dies ist umständlich und fehlerträchtig. So hat z.B. der einzige
bisherige Nutzer dieses Interfaces,
SL::DB::Order->convert_to_delivery_order, das bereits falsch gemacht und
vergessen, beim Lieferadressenobjekt die ID des neuen
Lieferscheinobjektes einzutragen. Somit wurden Lieferadressen erzeugt,
die keinerlei Verknüpfung hatten.
Das geänderte Interface hinterlegt das Objekt für die individuelle
Lieferadresse schlicht in $new_delivery_order->custom_shipto. Dort wird
das Objekt gespeichert, wenn der Lieferschein selber gespeichert wird.