Skip to content

Commit e226b45

Browse files
committed
- Improved StockProyecto model.
- Now we can disable Init from other plugins.
1 parent bf4ac87 commit e226b45

2 files changed

Lines changed: 29 additions & 6 deletions

File tree

Init.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,25 @@
3636
class Init extends InitClass
3737
{
3838

39+
/**
40+
*
41+
* @var bool
42+
*/
43+
private static $disableInit = false;
44+
45+
public static function disableInit()
46+
{
47+
self::$disableInit = true;
48+
}
49+
3950
public function init()
4051
{
41-
$this->loadExtension(new Extension\Controller\DocumentStitcher());
42-
$this->loadExtension(new Extension\Controller\EditCliente());
43-
$this->loadExtension(new Extension\Model\Base\BusinessDocument());
44-
$this->loadExtension(new Extension\Model\Base\BusinessDocumentLine());
52+
if (false === self::$disableInit) {
53+
$this->loadExtension(new Extension\Controller\DocumentStitcher());
54+
$this->loadExtension(new Extension\Controller\EditCliente());
55+
$this->loadExtension(new Extension\Model\Base\BusinessDocument());
56+
$this->loadExtension(new Extension\Model\Base\BusinessDocumentLine());
57+
}
4558
}
4659

4760
public function update()

Model/StockProyecto.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ public function getVariant()
104104
return $variant;
105105
}
106106

107+
/**
108+
*
109+
* @return Producto
110+
*/
111+
public function getProduct()
112+
{
113+
$product = new Producto();
114+
$product->loadFromCode($this->idproducto);
115+
return $product;
116+
}
117+
107118
/**
108119
*
109120
* @return string
@@ -112,7 +123,6 @@ public function install()
112123
{
113124
/// needed dependecies
114125
new Proyecto();
115-
new Producto();
116126
new Variante();
117127

118128
return parent::install();
@@ -169,6 +179,6 @@ public function test()
169179
*/
170180
public function url(string $type = 'auto', string $list = 'List'): string
171181
{
172-
return empty($this->primaryColumnValue()) ? parent::url($type, $list) : $this->getVariant()->url();
182+
return empty($this->primaryColumnValue()) ? parent::url($type, $list) : $this->getProduct()->url();
173183
}
174184
}

0 commit comments

Comments
 (0)