+sub get_title_for {
+ my ($self, $action) = @_;
+
+ return '' if none { lc($action)} qw(add edit);
+
+ # for locales:
+ # $::locale->text("Add Sales Order");
+ # $::locale->text("Add Purchase Order");
+ # $::locale->text("Add Quotation");
+ # $::locale->text("Add Request for Quotation");
+ # $::locale->text("Edit Sales Order");
+ # $::locale->text("Edit Purchase Order");
+ # $::locale->text("Edit Quotation");
+ # $::locale->text("Edit Request for Quotation");
+
+ $action = ucfirst(lc($action));
+ return $self->type eq sales_order_type() ? $::locale->text("$action Sales Order")
+ : $self->type eq purchase_order_type() ? $::locale->text("$action Purchase Order")
+ : $self->type eq sales_quotation_type() ? $::locale->text("$action Quotation")
+ : $self->type eq request_quotation_type() ? $::locale->text("$action Request for Quotation")
+ : '';
+}
+
+sub get_item_cvpartnumber {
+ my ($self, $item) = @_;
+
+ return if !$self->search_cvpartnumber;
+ return if !$self->order->customervendor;
+
+ if ($self->cv eq 'vendor') {
+ my @mms = grep { $_->make eq $self->order->customervendor->id } @{$item->part->makemodels};
+ $item->{cvpartnumber} = $mms[0]->model if scalar @mms;
+ } elsif ($self->cv eq 'customer') {
+ my @cps = grep { $_->customer_id eq $self->order->customervendor->id } @{$item->part->customerprices};
+ $item->{cvpartnumber} = $cps[0]->customer_partnumber if scalar @cps;
+ }
+}
+
+sub get_part_texts {
+ my ($part_or_id, $language_or_id, %defaults) = @_;
+
+ my $part = ref($part_or_id) ? $part_or_id : SL::DB::Part->load_cached($part_or_id);
+ my $language_id = ref($language_or_id) ? $language_or_id->id : $language_or_id;
+ my $texts = {
+ description => $defaults{description} // $part->description,
+ longdescription => $defaults{longdescription} // $part->notes,
+ };
+
+ return $texts unless $language_id;
+
+ my $translation = SL::DB::Manager::Translation->get_first(
+ where => [
+ parts_id => $part->id,
+ language_id => $language_id,
+ ]);
+
+ $texts->{description} = $translation->translation if $translation && $translation->translation;
+ $texts->{longdescription} = $translation->longdescription if $translation && $translation->longdescription;
+
+ return $texts;
+}
+
+sub sales_order_type {