Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1b18f0aa

Von Jan Büren vor mehr als 4 Jahren hinzugefügt

  • ID 1b18f0aa0914699d5ef4372243ebb8872d1bdc20
  • Vorgänger c45a00e0
  • Nachfolger 918c39c0

Mandanteneinstellung: Projekt zum Auftrag erzeugen auch für Order-Controller

Unterschiede anzeigen:

SL/DB/Order.pm
57 57
__PACKAGE__->attr_sorted('items');
58 58

  
59 59
__PACKAGE__->before_save('_before_save_set_ord_quo_number');
60
__PACKAGE__->before_save('_before_save_create_new_project');
60 61

  
61 62
# hooks
62 63

  
......
72 73

  
73 74
  return 1;
74 75
}
76
sub _before_save_create_new_project {
77
  my ($self) = @_;
78

  
79
  # force new project, if not set yet
80
  if ($::instance_conf->get_order_always_project && !$self->globalproject_id && ($self->type eq 'sales_order')) {
81

  
82
    die t8("Error while creating project with project number of new order number, project number #1 already exists!", $self->ordnumber)
83
      if SL::DB::Manager::Project->find_by(projectnumber => $self->ordnumber);
84

  
85
    eval {
86
      my $new_project = SL::DB::Project->new(
87
          projectnumber     => $self->ordnumber,
88
          description       => $self->customer->name,
89
          customer_id       => $self->customer->id,
90
          active            => 1,
91
          project_type_id   => $::instance_conf->get_project_type_id,
92
          project_status_id => $::instance_conf->get_project_status_id,
93
          );
94
       $new_project->save;
95
       $self->globalproject_id($new_project->id);
96
    } or die t8('Could not create new project #1', $@);
97
  }
98
  return 1;
99
}
75 100

  
76 101
# methods
77 102

  

Auch abrufbar als: Unified diff