fixed-asset-plugin 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Adrian Piney Gutierrez <adrian.piney@unican.es>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1 @@
1
+ recursive-include fixed_asset_plugin/static *
@@ -0,0 +1,46 @@
1
+ Metadata-Version: 2.4
2
+ Name: fixed_asset_plugin
3
+ Version: 0.1.0
4
+ Summary: Add Fixed Asset Parameter to every new Part created
5
+ Author: Adrian Piney Gutierrez
6
+ Author-email: adrian.piney@unican.es
7
+ License: MIT
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: inventree>=0.17.0
12
+ Dynamic: author
13
+ Dynamic: author-email
14
+ Dynamic: description
15
+ Dynamic: description-content-type
16
+ Dynamic: license
17
+ Dynamic: license-file
18
+ Dynamic: requires-dist
19
+ Dynamic: requires-python
20
+ Dynamic: summary
21
+
22
+ # FixedAssetPlugin
23
+
24
+ Add Fixed Asset Parameter to every new Part created
25
+
26
+ ## Installation
27
+
28
+ ### InvenTree Plugin Manager
29
+
30
+ ... todo ...
31
+
32
+ ### Command Line
33
+
34
+ To install manually via the command line, run the following command:
35
+
36
+ ```bash
37
+ pip install fixed-asset-plugin
38
+ ```
39
+
40
+ ## Configuration
41
+
42
+ ... todo ...
43
+
44
+ ## Usage
45
+
46
+ ... todo ...
@@ -0,0 +1,25 @@
1
+ # FixedAssetPlugin
2
+
3
+ Add Fixed Asset Parameter to every new Part created
4
+
5
+ ## Installation
6
+
7
+ ### InvenTree Plugin Manager
8
+
9
+ ... todo ...
10
+
11
+ ### Command Line
12
+
13
+ To install manually via the command line, run the following command:
14
+
15
+ ```bash
16
+ pip install fixed-asset-plugin
17
+ ```
18
+
19
+ ## Configuration
20
+
21
+ ... todo ...
22
+
23
+ ## Usage
24
+
25
+ ... todo ...
@@ -0,0 +1,3 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ PLUGIN_VERSION = "0.1.0"
@@ -0,0 +1,110 @@
1
+ """Add Fixed Asset Parameter to every new Part created"""
2
+
3
+ from plugin import InvenTreePlugin
4
+
5
+ from plugin.mixins import EventMixin
6
+
7
+ from part.models import Part, PartParameter, PartParameterTemplate
8
+
9
+ from . import PLUGIN_VERSION
10
+
11
+ import logging
12
+ from typing import Optional
13
+ # import os
14
+
15
+ logger = logging.getLogger(__name__)
16
+
17
+
18
+ class FixedAssetPlugin(EventMixin, InvenTreePlugin):
19
+
20
+ """FixedAssetPlugin - custom InvenTree plugin."""
21
+
22
+ # Plugin metadata
23
+ TITLE = "Fixed Asset Plugin"
24
+ NAME = "FixedAssetPlugin"
25
+ SLUG = "fixed-asset-plugin"
26
+ DESCRIPTION = "Add Fixed Asset Parameter to every new Part created"
27
+ VERSION = PLUGIN_VERSION
28
+ AUTHOR = "Adrian Piney Gutierrez"
29
+ LICENSE = "MIT"
30
+
31
+ # Variables
32
+
33
+ TEMPLATE_NAME = "Fixed Asset"
34
+ # TEMPLATE_ID = ""
35
+
36
+ # Optionally specify supported InvenTree versions
37
+ # MIN_VERSION = '0.18.0'
38
+ # MAX_VERSION = '2.0.0'
39
+
40
+ def __init__(self):
41
+ super().__init__()
42
+ self.logger = logging.getLogger(f"plugin.{self.SLUG}")
43
+ try:
44
+ self.template = PartParameterTemplate.objects.get(name=self.TEMPLATE_NAME)
45
+
46
+ except PartParameterTemplate.DoesNotExist:
47
+ self.template = None
48
+ logger.error(f"Template {self.TEMPLATE_NAME} not found")
49
+
50
+
51
+ # Configure custom logger to write to file
52
+ # log_dir = '/home/inventree/data/log'
53
+ # os.makedirs(log_dir, exist_ok=True)
54
+ # log_file = os.path.join(log_dir, 'fixed_asset_plugin.log')
55
+
56
+ # self.logger = logging.getLogger(self.NAME)
57
+ # self.logger.setLevel(logging.INFO)
58
+
59
+ # file_handler = logging.FileHandler(log_file)
60
+ # file_handler.setFormatter(logging.Formatter('[%(asctime)s] %(levelname)s: %(message)s'))
61
+
62
+ # # Prevent duplicate handlers on reload
63
+ # if not self.logger.handlers:
64
+ # self.logger.addHandler(file_handler)
65
+ # =============================================
66
+
67
+ def _get_part_from_event(self, *, args, kwargs) -> Optional[Part]:
68
+ if kwargs.get('model') != 'Part':
69
+ return None
70
+
71
+ pid = kwargs.get('id')
72
+ if pid is not None:
73
+ return Part.objects.filter(pk=pid).first()
74
+ return None
75
+
76
+
77
+ # Respond to InvenTree events (from EventMixin)
78
+ # Ref: https://docs.inventree.org/en/stable/extend/plugins/event/
79
+ def wants_process_event(self, event: str) -> bool:
80
+ """Return True if the plugin wants to process the given event."""
81
+ return event == 'part_part.created'
82
+
83
+ def process_event(self, event: str, *args, **kwargs) -> None:
84
+
85
+ # Check de los args para comprobar datos
86
+ self.logger.debug(f"fixed-asset-plugin args={args}, kwargs={kwargs}")
87
+
88
+ part = self._get_part_from_event(args=args, kwargs=kwargs)
89
+
90
+ if not part:
91
+ self.logger.debug("Ignoring event: not a Part or not ID")
92
+ return
93
+
94
+ if not self.template:
95
+ return
96
+
97
+ if PartParameter.objects.filter(part=part, template=self.template).exists():
98
+ self.logger.debug(f"Part {part.pk} ya tiene '{self.template.name}'")
99
+ return
100
+
101
+ try:
102
+ PartParameter.objects.create(
103
+ part=part,
104
+ template=self.template,
105
+ data=False
106
+ )
107
+ self.logger.info(f"Added '{self.template.name}' parameter to Part {part.pk}")
108
+
109
+ except Exception as e:
110
+ self.logger.error(f"Error adding parameter: {e}")
@@ -0,0 +1,46 @@
1
+ Metadata-Version: 2.4
2
+ Name: fixed_asset_plugin
3
+ Version: 0.1.0
4
+ Summary: Add Fixed Asset Parameter to every new Part created
5
+ Author: Adrian Piney Gutierrez
6
+ Author-email: adrian.piney@unican.es
7
+ License: MIT
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: inventree>=0.17.0
12
+ Dynamic: author
13
+ Dynamic: author-email
14
+ Dynamic: description
15
+ Dynamic: description-content-type
16
+ Dynamic: license
17
+ Dynamic: license-file
18
+ Dynamic: requires-dist
19
+ Dynamic: requires-python
20
+ Dynamic: summary
21
+
22
+ # FixedAssetPlugin
23
+
24
+ Add Fixed Asset Parameter to every new Part created
25
+
26
+ ## Installation
27
+
28
+ ### InvenTree Plugin Manager
29
+
30
+ ... todo ...
31
+
32
+ ### Command Line
33
+
34
+ To install manually via the command line, run the following command:
35
+
36
+ ```bash
37
+ pip install fixed-asset-plugin
38
+ ```
39
+
40
+ ## Configuration
41
+
42
+ ... todo ...
43
+
44
+ ## Usage
45
+
46
+ ... todo ...
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ setup.cfg
6
+ setup.py
7
+ fixed_asset_plugin/__init__.py
8
+ fixed_asset_plugin/core.py
9
+ fixed_asset_plugin.egg-info/PKG-INFO
10
+ fixed_asset_plugin.egg-info/SOURCES.txt
11
+ fixed_asset_plugin.egg-info/dependency_links.txt
12
+ fixed_asset_plugin.egg-info/entry_points.txt
13
+ fixed_asset_plugin.egg-info/requires.txt
14
+ fixed_asset_plugin.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [inventree_plugins]
2
+ fixed-asset-plugin = fixed_asset_plugin.core:FixedAssetPlugin
@@ -0,0 +1 @@
1
+ inventree>=0.17.0
@@ -0,0 +1 @@
1
+ fixed_asset_plugin
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,19 @@
1
+ [flake8]
2
+ ignore =
3
+ W293,
4
+ E501
5
+ N802
6
+ exclude =
7
+ .git,
8
+ __pycache__,
9
+ dist,
10
+ build,
11
+ src/static,
12
+ frontend/node_modules,
13
+ test.py
14
+ max-complexity = 20
15
+
16
+ [egg_info]
17
+ tag_build =
18
+ tag_date = 0
19
+
@@ -0,0 +1,48 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ import importlib
4
+ import importlib.util
5
+ import os
6
+ import setuptools
7
+
8
+ """This file is used to package the FixedAssetPlugin plugin.
9
+
10
+ - It was generated by the InvenTree Plugin Creator tool - version 1.1.0
11
+ - Ref: https://github.com/inventree/plugin_creator
12
+ """
13
+
14
+ """Read the plugin version from the source code."""
15
+ module_path = os.path.join(os.path.dirname(__file__), "fixed_asset_plugin", "__init__.py")
16
+ spec = importlib.util.spec_from_file_location("fixed_asset_plugin", module_path)
17
+ fixed_asset_plugin = importlib.util.module_from_spec(spec)
18
+ spec.loader.exec_module(fixed_asset_plugin)
19
+
20
+ with open('README.md', encoding='utf-8') as f:
21
+ long_description = f.read()
22
+
23
+ setuptools.setup(
24
+ name="fixed_asset_plugin",
25
+ version=fixed_asset_plugin.PLUGIN_VERSION,
26
+ author="Adrian Piney Gutierrez",
27
+ author_email="adrian.piney@unican.es",
28
+ description="Add Fixed Asset Parameter to every new Part created",
29
+ long_description=long_description,
30
+ long_description_content_type='text/markdown',
31
+ license="MIT",
32
+ packages=setuptools.find_packages(),
33
+ include_package_data=True,
34
+ install_requires=[
35
+ "inventree>=0.17.0"
36
+ ],
37
+ setup_requires=[
38
+ "wheel",
39
+ "twine",
40
+ ],
41
+ python_requires=">=3.9",
42
+ entry_points={
43
+ "inventree_plugins": [
44
+ # "FixedAssetPlugin = fixed_asset_plugin.core:FixedAssetPlugin"
45
+ "fixed-asset-plugin = fixed_asset_plugin.core:FixedAssetPlugin"
46
+ ]
47
+ },
48
+ )