oneCInteraction 1.2.3__tar.gz → 1.2.5__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.
- {onecinteraction-1.2.3/src/oneCInteraction.egg-info → onecinteraction-1.2.5}/PKG-INFO +40 -11
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/README.md +39 -10
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction/__init__.py +2 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction/connection.py +2 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction/nomenclature.py +155 -8
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction/structures.py +13 -1
- {onecinteraction-1.2.3 → onecinteraction-1.2.5/src/oneCInteraction.egg-info}/PKG-INFO +40 -11
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction.egg-info/scm_file_list.json +11 -11
- onecinteraction-1.2.5/src/oneCInteraction.egg-info/scm_version.json +8 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/tests/test_lib.py +31 -4
- onecinteraction-1.2.3/src/oneCInteraction.egg-info/scm_version.json +0 -8
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/.github/workflows/publish.yml +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/.gitignore +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/LICENSE +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/pyproject.toml +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/setup.cfg +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction/categories.py +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction/characteristics.py +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction/customers.py +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction/discounts.py +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction/groups.py +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction/log.py +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction/orders.py +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction.egg-info/SOURCES.txt +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction.egg-info/dependency_links.txt +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction.egg-info/requires.txt +0 -0
- {onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: oneCInteraction
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.5
|
|
4
4
|
Summary: A Python library for interacting with 1C:Enterprise databases via COM connection.
|
|
5
5
|
Author: agcl
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -21,6 +21,7 @@ A modular Python library for interacting with «1C:Enterprise» databases via a
|
|
|
21
21
|
- **Full COM Connection Support** via `win32com`.
|
|
22
22
|
- **Nomenclature and Categories Management**: retrieve group trees, batch load products, prices, and stock balances across warehouses.
|
|
23
23
|
- **Product Characteristics**: read variant properties from information registers or parse text descriptions.
|
|
24
|
+
- **Product Properties (Metadata)**: read and write general metadata (properties) of Nomenclature items to/from information registers.
|
|
24
25
|
- **Images**: download product images directly from the 1C database to the local disk.
|
|
25
26
|
- **Order Management**: create customer orders, track statuses, and update document comments with customer contact details.
|
|
26
27
|
- **Smart Logging**: automatically creates log files in the directory of the host project importing the library.
|
|
@@ -48,6 +49,7 @@ The library is built on the principle of composition: the main `Connection` clas
|
|
|
48
49
|
- `Connection.orders` (`OrdersManager`) — handles creation and updates of customer orders.
|
|
49
50
|
- `Connection.customers` (`CustomersManager`) — manages customers/counterparties.
|
|
50
51
|
- `Connection.discounts` (`DiscountsManager`) — manages discount groups and active nomenclature discounts.
|
|
52
|
+
- `Connection.properties` (`PropertiesManager`) — manages reading and writing general product properties.
|
|
51
53
|
|
|
52
54
|
---
|
|
53
55
|
|
|
@@ -68,7 +70,7 @@ def __init__(self, s_oneCDatabasePathIn: str, s_usernameIn: str, s_passwordIn: s
|
|
|
68
70
|
- `s_warehouse_code` (str): 1C warehouse code for new orders.
|
|
69
71
|
- `s_counteragent_code` (str): 1C counteragent (customer) code for new orders.
|
|
70
72
|
- `s_organisation_code` (str): 1C organization code for new orders.
|
|
71
|
-
- `sl_price_types` (list): List of price type names to cache automatically (defaults to `["Розничная", "Оптовая"]`).
|
|
73
|
+
- `sl_price_types` (list): List of price type names to cache automatically (defaults to `["Розничная", "Оптовая", "Закупочная"]`).
|
|
72
74
|
- `c_v8`: The active 1C COM connection object (equals `None` if not connected).
|
|
73
75
|
|
|
74
76
|
#### Methods:
|
|
@@ -92,6 +94,8 @@ Represents a product.
|
|
|
92
94
|
- `s_uuid` (str): Unique identifier (UUID) of the product in 1C.
|
|
93
95
|
- `s_code` (str): 1C product code.
|
|
94
96
|
- `l_images` (list): List of image UUIDs associated with the product in 1C.
|
|
97
|
+
- `dt_last_arrival` (datetime): Date of the last physical arrival of the product to the warehouse from 1C.
|
|
98
|
+
- `l_properties` (list of `Property`): List of general properties (metadata) of the product.
|
|
95
99
|
|
|
96
100
|
#### `Price`
|
|
97
101
|
Represents a price with its value, assignment date, and type.
|
|
@@ -112,6 +116,11 @@ A key-value pair for a variant property.
|
|
|
112
116
|
- `s_name` (str): Property name (e.g., `"Color"`).
|
|
113
117
|
- `s_value` (str): Property value (e.g., `"Red"`).
|
|
114
118
|
|
|
119
|
+
#### `Property`
|
|
120
|
+
A key-value pair for a product property (metadata).
|
|
121
|
+
- `s_name` (str): Property name (e.g., `"Material"`).
|
|
122
|
+
- `s_value` (str): Property value (e.g., `"Cotton"`).
|
|
123
|
+
|
|
115
124
|
#### `Group`
|
|
116
125
|
A product group (category).
|
|
117
126
|
- `s_name` (str): Group name.
|
|
@@ -153,6 +162,8 @@ A buyer's order.
|
|
|
153
162
|
- `s_status` (str): Status of the order in 1C.
|
|
154
163
|
- `s_date` (str): Order creation date (automatically generated).
|
|
155
164
|
- `n_orderCode` (str / int): Order number in 1C.
|
|
165
|
+
- `s_price_type` (str): Price type name used for the order (e.g. `"Розничная"`, `"Оптовая"`, `"Закупочная"`).
|
|
166
|
+
- `s_comment` (str): Additional comment/notes for the order (often parsed to extract Telegram ID).
|
|
156
167
|
|
|
157
168
|
Calling `str(order_obj)` returns a nicely formatted HTML string suitable for sending to a Telegram bot.
|
|
158
169
|
|
|
@@ -170,13 +181,15 @@ Represents a group of nomenclature discounts.
|
|
|
170
181
|
Defined in [nomenclature.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/src/oneCInteraction/nomenclature.py).
|
|
171
182
|
|
|
172
183
|
- `get(s_articleIn: str = "", s_nameIn: str = "", s_codeIn: str = "") -> Nomenclature | None`
|
|
173
|
-
Searches for and returns a product by its article, name, or code. Fetches retail
|
|
184
|
+
Searches for and returns a product by its article, name, or code. Fetches retail, wholesale, and purchase prices, stock balances by warehouses, characteristics, and the parent group's UUID (`s_parent_uuid`).
|
|
185
|
+
- `search(s_queryIn: str, s_searchByIn: str = "all") -> list`
|
|
186
|
+
Searches for nomenclature items by a query string matching the name, article, code, or all of them. Returns a list of `Nomenclature` objects (without full detailed price/stock breakdown, but containing basic fields).
|
|
174
187
|
- `get_images(c_productObjIn: Nomenclature, s_imageDirIn: str = None) -> list`
|
|
175
188
|
Downloads all attached images for a product from 1C. Saves them in the specified directory `s_imageDirIn` (defaults to `data/images`). Returns a list of the saved filenames (e.g., `["[uuid]_0.jpg"]`).
|
|
176
189
|
- `get_by_group(c_groupRefIn) -> list`
|
|
177
190
|
Batch fetches all products within a specific 1C group. Using optimized COM queries, this method minimizes DB requests and operates significantly faster than calling `get()` sequentially in a loop.
|
|
178
|
-
- `get_by_category(c_categoryIn
|
|
179
|
-
Batch fetches all products within a specific 1C category
|
|
191
|
+
- `get_by_category(c_categoryIn) -> list`
|
|
192
|
+
Batch fetches all products within a specific 1C category. `c_categoryIn` can be a COM reference object or a string representing the category name (searched within `Справочник.КатегорииОбъектов`).
|
|
180
193
|
|
|
181
194
|
---
|
|
182
195
|
|
|
@@ -196,9 +209,9 @@ Defined in [groups.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/
|
|
|
196
209
|
Defined in [categories.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/src/oneCInteraction/categories.py).
|
|
197
210
|
|
|
198
211
|
- `get(s_codeIn: str = "", s_nameIn: str = "") -> Category | None`
|
|
199
|
-
Finds a single Category by its code or name in the
|
|
212
|
+
Finds a single Category by its code or name in the `КатегорииОбъектов` (Object Categories) catalog.
|
|
200
213
|
- `create(s_nameIn: str) -> Category | None`
|
|
201
|
-
Creates a new Category with the specified name in
|
|
214
|
+
Creates a new Category with the specified name in `Справочник.КатегорииОбъектов` and returns it.
|
|
202
215
|
|
|
203
216
|
---
|
|
204
217
|
|
|
@@ -220,12 +233,12 @@ Defined in [orders.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/
|
|
|
220
233
|
- `push(c_orderObjIn: Order) -> str`
|
|
221
234
|
Creates a new `"Заказ покупателя"` (Buyer's Order) document in 1C.
|
|
222
235
|
- Automatically queries the warehouse, counteragent, and organization based on codes specified in the `Connection` object.
|
|
223
|
-
- Sets the
|
|
224
|
-
- Adds products from the order, queries the exact price for the specific characteristic selected, and computes totals.
|
|
236
|
+
- Sets the price type (defaulting to `"Розничная"` or using `s_price_type` from the order), document currency (Hryvnia, code `"980"`), and organization's primary bank account.
|
|
237
|
+
- Adds products from the order, queries/compares the exact price for the specific characteristic selected (using `s_price_type` to determine retail, wholesale, or purchase price), and computes totals.
|
|
225
238
|
- Attempts to post the document (`Posting`). If posting fails, it writes the document in draft/save mode (`Write`).
|
|
226
239
|
- Returns the number of the created document in 1C (or an empty string on error).
|
|
227
240
|
- `get(s_codeIn: str) -> Order | None`
|
|
228
|
-
Retrieves a buyer's order by its 1C document number and parses it into an `Order` object. The comment field is parsed to retrieve the Telegram ID.
|
|
241
|
+
Retrieves a buyer's order by its 1C document number and parses it into an `Order` object. The comment field is parsed to retrieve the Telegram ID, and the price type is retrieved.
|
|
229
242
|
- `get_today() -> list`
|
|
230
243
|
Returns a list of all today's orders created for the configured bot counteragent (filtered by current date and counteragent code).
|
|
231
244
|
- `update_info(c_orderObjIn: Order) -> bool`
|
|
@@ -259,7 +272,23 @@ Defined in [discounts.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionL
|
|
|
259
272
|
|
|
260
273
|
---
|
|
261
274
|
|
|
262
|
-
### 10.
|
|
275
|
+
### 10. Properties Manager `PropertiesManager` (`Connection.properties`)
|
|
276
|
+
Defined in [properties.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/src/oneCInteraction/properties.py).
|
|
277
|
+
|
|
278
|
+
- `write(self, c_productIn, s_propertyNameOrCodeIn: str, s_propertyValueIn: str) -> bool`
|
|
279
|
+
Writes or updates a single property value for a product (Nomenclature item).
|
|
280
|
+
- `write_batch(self, c_productIn, l_propertiesIn: list, b_forceIn: bool = False) -> list`
|
|
281
|
+
Writes/updates multiple properties for a product using a single 1C RecordSet. `l_propertiesIn` can be a list of `Property` objects or dicts `{"name": "...", "value": "..."}`.
|
|
282
|
+
- `get_assigned_properties(self, c_productIn) -> list`
|
|
283
|
+
Returns a list of `Property` objects assigned to the specified product.
|
|
284
|
+
- `delete(self, c_productIn, s_propertyNameOrCodeIn: str) -> bool`
|
|
285
|
+
Removes a specific property from a product in 1C register.
|
|
286
|
+
- `get_all_definitions(self) -> list`
|
|
287
|
+
Retrieves definitions of all active properties in 1C.
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
### 11. Logging (`log.py`)
|
|
263
292
|
Defined in [log.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/src/oneCInteraction/log.py).
|
|
264
293
|
|
|
265
294
|
All actions are logged automatically. The library resolves the root directory of the project that imported it and stores log files in the relative path `log/system/[calling_module_name].log`.
|
|
@@ -6,6 +6,7 @@ A modular Python library for interacting with «1C:Enterprise» databases via a
|
|
|
6
6
|
- **Full COM Connection Support** via `win32com`.
|
|
7
7
|
- **Nomenclature and Categories Management**: retrieve group trees, batch load products, prices, and stock balances across warehouses.
|
|
8
8
|
- **Product Characteristics**: read variant properties from information registers or parse text descriptions.
|
|
9
|
+
- **Product Properties (Metadata)**: read and write general metadata (properties) of Nomenclature items to/from information registers.
|
|
9
10
|
- **Images**: download product images directly from the 1C database to the local disk.
|
|
10
11
|
- **Order Management**: create customer orders, track statuses, and update document comments with customer contact details.
|
|
11
12
|
- **Smart Logging**: automatically creates log files in the directory of the host project importing the library.
|
|
@@ -33,6 +34,7 @@ The library is built on the principle of composition: the main `Connection` clas
|
|
|
33
34
|
- `Connection.orders` (`OrdersManager`) — handles creation and updates of customer orders.
|
|
34
35
|
- `Connection.customers` (`CustomersManager`) — manages customers/counterparties.
|
|
35
36
|
- `Connection.discounts` (`DiscountsManager`) — manages discount groups and active nomenclature discounts.
|
|
37
|
+
- `Connection.properties` (`PropertiesManager`) — manages reading and writing general product properties.
|
|
36
38
|
|
|
37
39
|
---
|
|
38
40
|
|
|
@@ -53,7 +55,7 @@ def __init__(self, s_oneCDatabasePathIn: str, s_usernameIn: str, s_passwordIn: s
|
|
|
53
55
|
- `s_warehouse_code` (str): 1C warehouse code for new orders.
|
|
54
56
|
- `s_counteragent_code` (str): 1C counteragent (customer) code for new orders.
|
|
55
57
|
- `s_organisation_code` (str): 1C organization code for new orders.
|
|
56
|
-
- `sl_price_types` (list): List of price type names to cache automatically (defaults to `["Розничная", "Оптовая"]`).
|
|
58
|
+
- `sl_price_types` (list): List of price type names to cache automatically (defaults to `["Розничная", "Оптовая", "Закупочная"]`).
|
|
57
59
|
- `c_v8`: The active 1C COM connection object (equals `None` if not connected).
|
|
58
60
|
|
|
59
61
|
#### Methods:
|
|
@@ -77,6 +79,8 @@ Represents a product.
|
|
|
77
79
|
- `s_uuid` (str): Unique identifier (UUID) of the product in 1C.
|
|
78
80
|
- `s_code` (str): 1C product code.
|
|
79
81
|
- `l_images` (list): List of image UUIDs associated with the product in 1C.
|
|
82
|
+
- `dt_last_arrival` (datetime): Date of the last physical arrival of the product to the warehouse from 1C.
|
|
83
|
+
- `l_properties` (list of `Property`): List of general properties (metadata) of the product.
|
|
80
84
|
|
|
81
85
|
#### `Price`
|
|
82
86
|
Represents a price with its value, assignment date, and type.
|
|
@@ -97,6 +101,11 @@ A key-value pair for a variant property.
|
|
|
97
101
|
- `s_name` (str): Property name (e.g., `"Color"`).
|
|
98
102
|
- `s_value` (str): Property value (e.g., `"Red"`).
|
|
99
103
|
|
|
104
|
+
#### `Property`
|
|
105
|
+
A key-value pair for a product property (metadata).
|
|
106
|
+
- `s_name` (str): Property name (e.g., `"Material"`).
|
|
107
|
+
- `s_value` (str): Property value (e.g., `"Cotton"`).
|
|
108
|
+
|
|
100
109
|
#### `Group`
|
|
101
110
|
A product group (category).
|
|
102
111
|
- `s_name` (str): Group name.
|
|
@@ -138,6 +147,8 @@ A buyer's order.
|
|
|
138
147
|
- `s_status` (str): Status of the order in 1C.
|
|
139
148
|
- `s_date` (str): Order creation date (automatically generated).
|
|
140
149
|
- `n_orderCode` (str / int): Order number in 1C.
|
|
150
|
+
- `s_price_type` (str): Price type name used for the order (e.g. `"Розничная"`, `"Оптовая"`, `"Закупочная"`).
|
|
151
|
+
- `s_comment` (str): Additional comment/notes for the order (often parsed to extract Telegram ID).
|
|
141
152
|
|
|
142
153
|
Calling `str(order_obj)` returns a nicely formatted HTML string suitable for sending to a Telegram bot.
|
|
143
154
|
|
|
@@ -155,13 +166,15 @@ Represents a group of nomenclature discounts.
|
|
|
155
166
|
Defined in [nomenclature.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/src/oneCInteraction/nomenclature.py).
|
|
156
167
|
|
|
157
168
|
- `get(s_articleIn: str = "", s_nameIn: str = "", s_codeIn: str = "") -> Nomenclature | None`
|
|
158
|
-
Searches for and returns a product by its article, name, or code. Fetches retail
|
|
169
|
+
Searches for and returns a product by its article, name, or code. Fetches retail, wholesale, and purchase prices, stock balances by warehouses, characteristics, and the parent group's UUID (`s_parent_uuid`).
|
|
170
|
+
- `search(s_queryIn: str, s_searchByIn: str = "all") -> list`
|
|
171
|
+
Searches for nomenclature items by a query string matching the name, article, code, or all of them. Returns a list of `Nomenclature` objects (without full detailed price/stock breakdown, but containing basic fields).
|
|
159
172
|
- `get_images(c_productObjIn: Nomenclature, s_imageDirIn: str = None) -> list`
|
|
160
173
|
Downloads all attached images for a product from 1C. Saves them in the specified directory `s_imageDirIn` (defaults to `data/images`). Returns a list of the saved filenames (e.g., `["[uuid]_0.jpg"]`).
|
|
161
174
|
- `get_by_group(c_groupRefIn) -> list`
|
|
162
175
|
Batch fetches all products within a specific 1C group. Using optimized COM queries, this method minimizes DB requests and operates significantly faster than calling `get()` sequentially in a loop.
|
|
163
|
-
- `get_by_category(c_categoryIn
|
|
164
|
-
Batch fetches all products within a specific 1C category
|
|
176
|
+
- `get_by_category(c_categoryIn) -> list`
|
|
177
|
+
Batch fetches all products within a specific 1C category. `c_categoryIn` can be a COM reference object or a string representing the category name (searched within `Справочник.КатегорииОбъектов`).
|
|
165
178
|
|
|
166
179
|
---
|
|
167
180
|
|
|
@@ -181,9 +194,9 @@ Defined in [groups.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/
|
|
|
181
194
|
Defined in [categories.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/src/oneCInteraction/categories.py).
|
|
182
195
|
|
|
183
196
|
- `get(s_codeIn: str = "", s_nameIn: str = "") -> Category | None`
|
|
184
|
-
Finds a single Category by its code or name in the
|
|
197
|
+
Finds a single Category by its code or name in the `КатегорииОбъектов` (Object Categories) catalog.
|
|
185
198
|
- `create(s_nameIn: str) -> Category | None`
|
|
186
|
-
Creates a new Category with the specified name in
|
|
199
|
+
Creates a new Category with the specified name in `Справочник.КатегорииОбъектов` and returns it.
|
|
187
200
|
|
|
188
201
|
---
|
|
189
202
|
|
|
@@ -205,12 +218,12 @@ Defined in [orders.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/
|
|
|
205
218
|
- `push(c_orderObjIn: Order) -> str`
|
|
206
219
|
Creates a new `"Заказ покупателя"` (Buyer's Order) document in 1C.
|
|
207
220
|
- Automatically queries the warehouse, counteragent, and organization based on codes specified in the `Connection` object.
|
|
208
|
-
- Sets the
|
|
209
|
-
- Adds products from the order, queries the exact price for the specific characteristic selected, and computes totals.
|
|
221
|
+
- Sets the price type (defaulting to `"Розничная"` or using `s_price_type` from the order), document currency (Hryvnia, code `"980"`), and organization's primary bank account.
|
|
222
|
+
- Adds products from the order, queries/compares the exact price for the specific characteristic selected (using `s_price_type` to determine retail, wholesale, or purchase price), and computes totals.
|
|
210
223
|
- Attempts to post the document (`Posting`). If posting fails, it writes the document in draft/save mode (`Write`).
|
|
211
224
|
- Returns the number of the created document in 1C (or an empty string on error).
|
|
212
225
|
- `get(s_codeIn: str) -> Order | None`
|
|
213
|
-
Retrieves a buyer's order by its 1C document number and parses it into an `Order` object. The comment field is parsed to retrieve the Telegram ID.
|
|
226
|
+
Retrieves a buyer's order by its 1C document number and parses it into an `Order` object. The comment field is parsed to retrieve the Telegram ID, and the price type is retrieved.
|
|
214
227
|
- `get_today() -> list`
|
|
215
228
|
Returns a list of all today's orders created for the configured bot counteragent (filtered by current date and counteragent code).
|
|
216
229
|
- `update_info(c_orderObjIn: Order) -> bool`
|
|
@@ -244,7 +257,23 @@ Defined in [discounts.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionL
|
|
|
244
257
|
|
|
245
258
|
---
|
|
246
259
|
|
|
247
|
-
### 10.
|
|
260
|
+
### 10. Properties Manager `PropertiesManager` (`Connection.properties`)
|
|
261
|
+
Defined in [properties.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/src/oneCInteraction/properties.py).
|
|
262
|
+
|
|
263
|
+
- `write(self, c_productIn, s_propertyNameOrCodeIn: str, s_propertyValueIn: str) -> bool`
|
|
264
|
+
Writes or updates a single property value for a product (Nomenclature item).
|
|
265
|
+
- `write_batch(self, c_productIn, l_propertiesIn: list, b_forceIn: bool = False) -> list`
|
|
266
|
+
Writes/updates multiple properties for a product using a single 1C RecordSet. `l_propertiesIn` can be a list of `Property` objects or dicts `{"name": "...", "value": "..."}`.
|
|
267
|
+
- `get_assigned_properties(self, c_productIn) -> list`
|
|
268
|
+
Returns a list of `Property` objects assigned to the specified product.
|
|
269
|
+
- `delete(self, c_productIn, s_propertyNameOrCodeIn: str) -> bool`
|
|
270
|
+
Removes a specific property from a product in 1C register.
|
|
271
|
+
- `get_all_definitions(self) -> list`
|
|
272
|
+
Retrieves definitions of all active properties in 1C.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
### 11. Logging (`log.py`)
|
|
248
277
|
Defined in [log.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/src/oneCInteraction/log.py).
|
|
249
278
|
|
|
250
279
|
All actions are logged automatically. The library resolves the root directory of the project that imported it and stores log files in the relative path `log/system/[calling_module_name].log`.
|
|
@@ -9,6 +9,7 @@ from .characteristics import CharacteristicsManager
|
|
|
9
9
|
from .categories import CategoriesManager
|
|
10
10
|
from .customers import CustomersManager
|
|
11
11
|
from .discounts import DiscountsManager
|
|
12
|
+
from .properties import PropertiesManager
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class Connection:
|
|
@@ -41,6 +42,7 @@ class Connection:
|
|
|
41
42
|
self.categories = CategoriesManager(self)
|
|
42
43
|
self.customers = CustomersManager(self)
|
|
43
44
|
self.discounts = DiscountsManager(self)
|
|
45
|
+
self.properties = PropertiesManager(self)
|
|
44
46
|
|
|
45
47
|
def initiate_connection(self) -> None:
|
|
46
48
|
"""Establishes COM connection to 1C and caches price type references."""
|
|
@@ -54,7 +54,8 @@ class NomenclatureManager:
|
|
|
54
54
|
Артикул AS Article,
|
|
55
55
|
ISNULL(ДополнительноеОписаниеНоменклатуры, "") AS FullDescription,
|
|
56
56
|
ISNULL(НаименованиеПолное, "") AS FullName,
|
|
57
|
-
ISNULL(ЕдиницаХраненияОстатков.Наименование, "шт.") AS Unit
|
|
57
|
+
ISNULL(ЕдиницаХраненияОстатков.Наименование, "шт.") AS Unit,
|
|
58
|
+
Родитель.Ссылка AS ParentRef
|
|
58
59
|
FROM Справочник.Номенклатура
|
|
59
60
|
WHERE ({" OR ".join(where_clauses)}) AND ЭтоГруппа = ЛОЖЬ AND ПометкаУдаления = ЛОЖЬ
|
|
60
61
|
"""
|
|
@@ -71,6 +72,8 @@ class NomenclatureManager:
|
|
|
71
72
|
if not s_description:
|
|
72
73
|
s_description = self.c_v8.String(c_selection.FullName)
|
|
73
74
|
|
|
75
|
+
s_parent_uuid = self.c_v8.String(c_selection.ParentRef.UUID()) if not c_selection.ParentRef.IsEmpty() else ""
|
|
76
|
+
|
|
74
77
|
log_sys(f"Nomenclature found: Name='{c_selection.Name}', Article='{c_selection.Article}'")
|
|
75
78
|
return self._fetch_details(
|
|
76
79
|
c_selection.Ref,
|
|
@@ -78,8 +81,9 @@ class NomenclatureManager:
|
|
|
78
81
|
c_selection.Article,
|
|
79
82
|
s_description,
|
|
80
83
|
getattr(c_selection, "Unit", "шт."),
|
|
81
|
-
self.c_v8.String(c_selection.Ref.UUID()),
|
|
82
|
-
self.c_v8.String(c_selection.Code)
|
|
84
|
+
self.c_v8.String(c_selection.Ref.UUID()),
|
|
85
|
+
self.c_v8.String(c_selection.Code),
|
|
86
|
+
s_parent_uuidIn=s_parent_uuid
|
|
83
87
|
)
|
|
84
88
|
except Exception as e:
|
|
85
89
|
log_sys(f"Error in NomenclatureManager.get: {e}", 1)
|
|
@@ -162,6 +166,8 @@ class NomenclatureManager:
|
|
|
162
166
|
return []
|
|
163
167
|
|
|
164
168
|
d_batchDetails = self._fetch_batch_details(l_productRefs)
|
|
169
|
+
d_batchArrivals = self._fetch_batch_last_arrivals(l_productRefs)
|
|
170
|
+
d_batchProperties = self._fetch_batch_properties(l_productRefs)
|
|
165
171
|
|
|
166
172
|
l_allCharRefs = []
|
|
167
173
|
for s_productUuid in d_batchDetails:
|
|
@@ -216,7 +222,9 @@ class NomenclatureManager:
|
|
|
216
222
|
s_unitIn=d_item["unit"],
|
|
217
223
|
s_uuidIn=s_productUuid,
|
|
218
224
|
s_codeIn=self.c_v8.String(d_item["code"]),
|
|
219
|
-
l_imagesIn=d_batchImages.get(s_productUuid, [])
|
|
225
|
+
l_imagesIn=d_batchImages.get(s_productUuid, []),
|
|
226
|
+
dt_last_arrivalIn=d_batchArrivals.get(s_productUuid),
|
|
227
|
+
l_propertiesIn=d_batchProperties.get(s_productUuid, [])
|
|
220
228
|
))
|
|
221
229
|
|
|
222
230
|
log_sys(f"Successfully processed {len(l_nomenclatures)} items in search mode.")
|
|
@@ -225,6 +233,47 @@ class NomenclatureManager:
|
|
|
225
233
|
log_sys(f"Error in NomenclatureManager.search (batch): {e}", 1)
|
|
226
234
|
return []
|
|
227
235
|
|
|
236
|
+
def _fetch_batch_properties(self, l_productRefsIn: list) -> dict:
|
|
237
|
+
"""Batch fetches properties and values for a list of product references."""
|
|
238
|
+
if not self.c_v8 or not l_productRefsIn:
|
|
239
|
+
return {}
|
|
240
|
+
|
|
241
|
+
log_sys(f"Batch fetching properties for {len(l_productRefsIn)} products...")
|
|
242
|
+
|
|
243
|
+
c_productRefsV8 = self.c_v8.NewObject("ValueList")
|
|
244
|
+
for c_ref in l_productRefsIn:
|
|
245
|
+
if c_ref and not c_ref.IsEmpty():
|
|
246
|
+
c_productRefsV8.Add(c_ref)
|
|
247
|
+
|
|
248
|
+
d_productProps = {} # {product_uuid: [Property]}
|
|
249
|
+
|
|
250
|
+
if c_productRefsV8.Count() > 0:
|
|
251
|
+
try:
|
|
252
|
+
c_propQuery = self.c_v8.NewObject("Query")
|
|
253
|
+
c_propQuery.Text = """
|
|
254
|
+
SELECT
|
|
255
|
+
Properties.Объект AS ProductRef,
|
|
256
|
+
Properties.Свойство.Наименование AS PropName,
|
|
257
|
+
Properties.Значение.Наименование AS ValName
|
|
258
|
+
FROM
|
|
259
|
+
РегистрСведений.ЗначенияСвойствОбъектов AS Properties
|
|
260
|
+
WHERE
|
|
261
|
+
Properties.Объект В (&ProductRefs)
|
|
262
|
+
"""
|
|
263
|
+
c_propQuery.SetParameter("ProductRefs", c_productRefsV8)
|
|
264
|
+
c_propRes = c_propQuery.Execute()
|
|
265
|
+
if c_propRes is not None and not c_propRes.IsEmpty():
|
|
266
|
+
c_sel = c_propRes.Select()
|
|
267
|
+
while c_sel.Next():
|
|
268
|
+
s_uuid = self.c_v8.String(c_sel.ProductRef.UUID())
|
|
269
|
+
if s_uuid not in d_productProps:
|
|
270
|
+
d_productProps[s_uuid] = []
|
|
271
|
+
d_productProps[s_uuid].append(structures.Property(c_sel.PropName, c_sel.ValName))
|
|
272
|
+
except Exception as e:
|
|
273
|
+
log_sys(f"Error batch fetching properties: {e}", 1)
|
|
274
|
+
|
|
275
|
+
return d_productProps
|
|
276
|
+
|
|
228
277
|
def _fetch_batch_details(self, l_productRefsIn: list) -> dict:
|
|
229
278
|
"""Batch fetches prices and stock quantities for a list of product references."""
|
|
230
279
|
if not self.c_v8 or not l_productRefsIn:
|
|
@@ -347,6 +396,47 @@ class NomenclatureManager:
|
|
|
347
396
|
|
|
348
397
|
return d_batchData
|
|
349
398
|
|
|
399
|
+
def _fetch_batch_last_arrivals(self, l_productRefsIn: list) -> dict:
|
|
400
|
+
"""Batch fetches the last physical arrival date for a list of product references."""
|
|
401
|
+
if not self.c_v8 or not l_productRefsIn:
|
|
402
|
+
return {}
|
|
403
|
+
|
|
404
|
+
log_sys(f"Batch fetching last arrival dates for {len(l_productRefsIn)} items...")
|
|
405
|
+
|
|
406
|
+
c_productRefsV8 = self.c_v8.NewObject("ValueList")
|
|
407
|
+
for c_ref in l_productRefsIn:
|
|
408
|
+
c_productRefsV8.Add(c_ref)
|
|
409
|
+
|
|
410
|
+
c_query = self.c_v8.NewObject("Query")
|
|
411
|
+
c_query.Text = """
|
|
412
|
+
SELECT
|
|
413
|
+
ТоварыНаСкладах.Номенклатура AS ProductRef,
|
|
414
|
+
MAX(ТоварыНаСкладах.Период) AS LastArrivalDate
|
|
415
|
+
FROM
|
|
416
|
+
РегистрНакопления.ТоварыНаСкладах AS ТоварыНаСкладах
|
|
417
|
+
WHERE
|
|
418
|
+
ТоварыНаСкладах.Номенклатура В (&ProductRefs)
|
|
419
|
+
AND ТоварыНаСкладах.ВидДвижения = ЗНАЧЕНИЕ(ВидДвиженияНакопления.Приход)
|
|
420
|
+
GROUP BY
|
|
421
|
+
ТоварыНаСкладах.Номенклатура
|
|
422
|
+
"""
|
|
423
|
+
c_query.SetParameter("ProductRefs", c_productRefsV8)
|
|
424
|
+
|
|
425
|
+
d_arrivals = {}
|
|
426
|
+
try:
|
|
427
|
+
c_result = c_query.Execute()
|
|
428
|
+
if c_result is not None and not c_result.IsEmpty():
|
|
429
|
+
c_sel = c_result.Select()
|
|
430
|
+
while c_sel.Next():
|
|
431
|
+
s_productUuid = self.c_v8.String(c_sel.ProductRef.UUID())
|
|
432
|
+
dt_last_arrival = _parse_1c_date(c_sel.LastArrivalDate)
|
|
433
|
+
if dt_last_arrival:
|
|
434
|
+
d_arrivals[s_productUuid] = dt_last_arrival
|
|
435
|
+
except Exception as e:
|
|
436
|
+
log_sys(f"Error in batch last arrivals query execution: {e}", 1)
|
|
437
|
+
|
|
438
|
+
return d_arrivals
|
|
439
|
+
|
|
350
440
|
def _fetch_batch_image_metadata(self, l_productRefsIn: list) -> dict:
|
|
351
441
|
"""Batch fetches image references (UUIDs) for a list of product references."""
|
|
352
442
|
if not self.c_v8 or not l_productRefsIn:
|
|
@@ -389,7 +479,8 @@ class NomenclatureManager:
|
|
|
389
479
|
s_descriptionIn: str,
|
|
390
480
|
s_unitIn: str = "шт.",
|
|
391
481
|
s_uuidIn: str = "",
|
|
392
|
-
s_codeIn: str = ""
|
|
482
|
+
s_codeIn: str = "",
|
|
483
|
+
s_parent_uuidIn: str = ""
|
|
393
484
|
):
|
|
394
485
|
"""Fetches details (prices, stock, characteristics) for a single Nomenclature."""
|
|
395
486
|
c_retailPtRef = self.c_connection.get_price_type_ref("Розничная")
|
|
@@ -527,6 +618,49 @@ class NomenclatureManager:
|
|
|
527
618
|
)
|
|
528
619
|
))
|
|
529
620
|
|
|
621
|
+
# Fetch last arrival date
|
|
622
|
+
dt_last_arrival = None
|
|
623
|
+
try:
|
|
624
|
+
c_arrivalQuery = self.c_v8.NewObject("Query")
|
|
625
|
+
c_arrivalQuery.Text = """
|
|
626
|
+
SELECT
|
|
627
|
+
MAX(ТоварыНаСкладах.Период) AS LastArrivalDate
|
|
628
|
+
FROM
|
|
629
|
+
РегистрНакопления.ТоварыНаСкладах AS ТоварыНаСкладах
|
|
630
|
+
WHERE
|
|
631
|
+
ТоварыНаСкладах.Номенклатура = &ProductRef
|
|
632
|
+
AND ТоварыНаСкладах.ВидДвижения = ЗНАЧЕНИЕ(ВидДвиженияНакопления.Приход)
|
|
633
|
+
"""
|
|
634
|
+
c_arrivalQuery.SetParameter("ProductRef", c_productRefIn)
|
|
635
|
+
c_arrivalResult = c_arrivalQuery.Execute()
|
|
636
|
+
if c_arrivalResult is not None and not c_arrivalResult.IsEmpty():
|
|
637
|
+
c_arrivalSel = c_arrivalResult.Select()
|
|
638
|
+
if c_arrivalSel.Next():
|
|
639
|
+
dt_last_arrival = _parse_1c_date(c_arrivalSel.LastArrivalDate)
|
|
640
|
+
except Exception as e:
|
|
641
|
+
log_sys(f"Error fetching last arrival date for {s_articleIn}: {e}", 1)
|
|
642
|
+
# Fetch product properties
|
|
643
|
+
l_properties = []
|
|
644
|
+
try:
|
|
645
|
+
c_propQuery = self.c_v8.NewObject("Query")
|
|
646
|
+
c_propQuery.Text = """
|
|
647
|
+
SELECT
|
|
648
|
+
Properties.Свойство.Наименование AS PropName,
|
|
649
|
+
Properties.Значение.Наименование AS ValName
|
|
650
|
+
FROM
|
|
651
|
+
РегистрСведений.ЗначенияСвойствОбъектов AS Properties
|
|
652
|
+
WHERE
|
|
653
|
+
Properties.Объект = &ProductRef
|
|
654
|
+
"""
|
|
655
|
+
c_propQuery.SetParameter("ProductRef", c_productRefIn)
|
|
656
|
+
c_propRes = c_propQuery.Execute()
|
|
657
|
+
if c_propRes is not None and not c_propRes.IsEmpty():
|
|
658
|
+
c_sel = c_propRes.Select()
|
|
659
|
+
while c_sel.Next():
|
|
660
|
+
l_properties.append(structures.Property(c_sel.PropName, c_sel.ValName))
|
|
661
|
+
except Exception as e:
|
|
662
|
+
log_sys(f"Error fetching properties for {s_articleIn}: {e}", 1)
|
|
663
|
+
|
|
530
664
|
return structures.Nomenclature(
|
|
531
665
|
s_nameIn=s_nameIn,
|
|
532
666
|
s_articleIn=s_articleIn,
|
|
@@ -534,7 +668,10 @@ class NomenclatureManager:
|
|
|
534
668
|
s_descriptionIn=s_descriptionIn,
|
|
535
669
|
s_unitIn=s_unitIn,
|
|
536
670
|
s_uuidIn=s_uuidIn,
|
|
537
|
-
s_codeIn=s_codeIn
|
|
671
|
+
s_codeIn=s_codeIn,
|
|
672
|
+
s_parent_uuidIn=s_parent_uuidIn,
|
|
673
|
+
dt_last_arrivalIn=dt_last_arrival,
|
|
674
|
+
l_propertiesIn=l_properties
|
|
538
675
|
)
|
|
539
676
|
|
|
540
677
|
def get_images(self, c_productObjIn, s_imageDirIn: str = None) -> list:
|
|
@@ -665,6 +802,8 @@ class NomenclatureManager:
|
|
|
665
802
|
|
|
666
803
|
|
|
667
804
|
d_batchDetails = self._fetch_batch_details(l_productRefs)
|
|
805
|
+
d_batchArrivals = self._fetch_batch_last_arrivals(l_productRefs)
|
|
806
|
+
d_batchProperties = self._fetch_batch_properties(l_productRefs)
|
|
668
807
|
|
|
669
808
|
|
|
670
809
|
l_allCharRefs = []
|
|
@@ -721,8 +860,11 @@ class NomenclatureManager:
|
|
|
721
860
|
l_varietyIn=l_varieties,
|
|
722
861
|
s_descriptionIn=d_item["description"],
|
|
723
862
|
s_unitIn=d_item["unit"],
|
|
863
|
+
s_uuidIn=s_productUuid,
|
|
724
864
|
s_codeIn=self.c_v8.String(d_item["code"]),
|
|
725
|
-
l_imagesIn=d_batchImages.get(s_productUuid, [])
|
|
865
|
+
l_imagesIn=d_batchImages.get(s_productUuid, []),
|
|
866
|
+
dt_last_arrivalIn=d_batchArrivals.get(s_productUuid),
|
|
867
|
+
l_propertiesIn=d_batchProperties.get(s_productUuid, [])
|
|
726
868
|
))
|
|
727
869
|
|
|
728
870
|
log_sys(f"Successfully processed {len(l_nomenclatures)} items in batch mode.")
|
|
@@ -818,6 +960,8 @@ class NomenclatureManager:
|
|
|
818
960
|
|
|
819
961
|
|
|
820
962
|
d_batchDetails = self._fetch_batch_details(l_productRefs)
|
|
963
|
+
d_batchArrivals = self._fetch_batch_last_arrivals(l_productRefs)
|
|
964
|
+
d_batchProperties = self._fetch_batch_properties(l_productRefs)
|
|
821
965
|
|
|
822
966
|
|
|
823
967
|
l_allCharRefs = []
|
|
@@ -874,8 +1018,11 @@ class NomenclatureManager:
|
|
|
874
1018
|
l_varietyIn=l_varieties,
|
|
875
1019
|
s_descriptionIn=d_item["description"],
|
|
876
1020
|
s_unitIn=d_item["unit"],
|
|
1021
|
+
s_uuidIn=s_productUuid,
|
|
877
1022
|
s_codeIn=self.c_v8.String(d_item["code"]),
|
|
878
|
-
l_imagesIn=d_batchImages.get(s_productUuid, [])
|
|
1023
|
+
l_imagesIn=d_batchImages.get(s_productUuid, []),
|
|
1024
|
+
dt_last_arrivalIn=d_batchArrivals.get(s_productUuid),
|
|
1025
|
+
l_propertiesIn=d_batchProperties.get(s_productUuid, [])
|
|
879
1026
|
))
|
|
880
1027
|
|
|
881
1028
|
log_sys(f"Successfully processed {len(l_nomenclatures)} items in batch mode.")
|
|
@@ -11,7 +11,9 @@ class Nomenclature:
|
|
|
11
11
|
s_parent_uuidIn: str = "",
|
|
12
12
|
s_uuidIn: str = "",
|
|
13
13
|
s_codeIn: str = "",
|
|
14
|
-
l_imagesIn: list = None
|
|
14
|
+
l_imagesIn: list = None,
|
|
15
|
+
dt_last_arrivalIn: datetime = None,
|
|
16
|
+
l_propertiesIn: list = None
|
|
15
17
|
):
|
|
16
18
|
self.s_name = s_nameIn
|
|
17
19
|
self.s_article = s_articleIn
|
|
@@ -22,6 +24,8 @@ class Nomenclature:
|
|
|
22
24
|
self.s_uuid = s_uuidIn
|
|
23
25
|
self.s_code = s_codeIn
|
|
24
26
|
self.l_images = l_imagesIn if l_imagesIn is not None else []
|
|
27
|
+
self.dt_last_arrival = dt_last_arrivalIn
|
|
28
|
+
self.l_properties = l_propertiesIn if l_propertiesIn is not None else []
|
|
25
29
|
|
|
26
30
|
class Price:
|
|
27
31
|
def __init__(self, n_value: float, dt_assigned: datetime = None, s_type: str = ""):
|
|
@@ -53,6 +57,14 @@ class Characteristic:
|
|
|
53
57
|
self.s_name = s_nameIn
|
|
54
58
|
self.s_value = s_valueIn
|
|
55
59
|
|
|
60
|
+
class Property:
|
|
61
|
+
def __init__(self, s_nameIn: str, s_valueIn: str):
|
|
62
|
+
self.s_name = s_nameIn
|
|
63
|
+
self.s_value = s_valueIn
|
|
64
|
+
|
|
65
|
+
def __repr__(self):
|
|
66
|
+
return f"Property(name='{self.s_name}', value='{self.s_value}')"
|
|
67
|
+
|
|
56
68
|
class Group:
|
|
57
69
|
def __init__(
|
|
58
70
|
self,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: oneCInteraction
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.5
|
|
4
4
|
Summary: A Python library for interacting with 1C:Enterprise databases via COM connection.
|
|
5
5
|
Author: agcl
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -21,6 +21,7 @@ A modular Python library for interacting with «1C:Enterprise» databases via a
|
|
|
21
21
|
- **Full COM Connection Support** via `win32com`.
|
|
22
22
|
- **Nomenclature and Categories Management**: retrieve group trees, batch load products, prices, and stock balances across warehouses.
|
|
23
23
|
- **Product Characteristics**: read variant properties from information registers or parse text descriptions.
|
|
24
|
+
- **Product Properties (Metadata)**: read and write general metadata (properties) of Nomenclature items to/from information registers.
|
|
24
25
|
- **Images**: download product images directly from the 1C database to the local disk.
|
|
25
26
|
- **Order Management**: create customer orders, track statuses, and update document comments with customer contact details.
|
|
26
27
|
- **Smart Logging**: automatically creates log files in the directory of the host project importing the library.
|
|
@@ -48,6 +49,7 @@ The library is built on the principle of composition: the main `Connection` clas
|
|
|
48
49
|
- `Connection.orders` (`OrdersManager`) — handles creation and updates of customer orders.
|
|
49
50
|
- `Connection.customers` (`CustomersManager`) — manages customers/counterparties.
|
|
50
51
|
- `Connection.discounts` (`DiscountsManager`) — manages discount groups and active nomenclature discounts.
|
|
52
|
+
- `Connection.properties` (`PropertiesManager`) — manages reading and writing general product properties.
|
|
51
53
|
|
|
52
54
|
---
|
|
53
55
|
|
|
@@ -68,7 +70,7 @@ def __init__(self, s_oneCDatabasePathIn: str, s_usernameIn: str, s_passwordIn: s
|
|
|
68
70
|
- `s_warehouse_code` (str): 1C warehouse code for new orders.
|
|
69
71
|
- `s_counteragent_code` (str): 1C counteragent (customer) code for new orders.
|
|
70
72
|
- `s_organisation_code` (str): 1C organization code for new orders.
|
|
71
|
-
- `sl_price_types` (list): List of price type names to cache automatically (defaults to `["Розничная", "Оптовая"]`).
|
|
73
|
+
- `sl_price_types` (list): List of price type names to cache automatically (defaults to `["Розничная", "Оптовая", "Закупочная"]`).
|
|
72
74
|
- `c_v8`: The active 1C COM connection object (equals `None` if not connected).
|
|
73
75
|
|
|
74
76
|
#### Methods:
|
|
@@ -92,6 +94,8 @@ Represents a product.
|
|
|
92
94
|
- `s_uuid` (str): Unique identifier (UUID) of the product in 1C.
|
|
93
95
|
- `s_code` (str): 1C product code.
|
|
94
96
|
- `l_images` (list): List of image UUIDs associated with the product in 1C.
|
|
97
|
+
- `dt_last_arrival` (datetime): Date of the last physical arrival of the product to the warehouse from 1C.
|
|
98
|
+
- `l_properties` (list of `Property`): List of general properties (metadata) of the product.
|
|
95
99
|
|
|
96
100
|
#### `Price`
|
|
97
101
|
Represents a price with its value, assignment date, and type.
|
|
@@ -112,6 +116,11 @@ A key-value pair for a variant property.
|
|
|
112
116
|
- `s_name` (str): Property name (e.g., `"Color"`).
|
|
113
117
|
- `s_value` (str): Property value (e.g., `"Red"`).
|
|
114
118
|
|
|
119
|
+
#### `Property`
|
|
120
|
+
A key-value pair for a product property (metadata).
|
|
121
|
+
- `s_name` (str): Property name (e.g., `"Material"`).
|
|
122
|
+
- `s_value` (str): Property value (e.g., `"Cotton"`).
|
|
123
|
+
|
|
115
124
|
#### `Group`
|
|
116
125
|
A product group (category).
|
|
117
126
|
- `s_name` (str): Group name.
|
|
@@ -153,6 +162,8 @@ A buyer's order.
|
|
|
153
162
|
- `s_status` (str): Status of the order in 1C.
|
|
154
163
|
- `s_date` (str): Order creation date (automatically generated).
|
|
155
164
|
- `n_orderCode` (str / int): Order number in 1C.
|
|
165
|
+
- `s_price_type` (str): Price type name used for the order (e.g. `"Розничная"`, `"Оптовая"`, `"Закупочная"`).
|
|
166
|
+
- `s_comment` (str): Additional comment/notes for the order (often parsed to extract Telegram ID).
|
|
156
167
|
|
|
157
168
|
Calling `str(order_obj)` returns a nicely formatted HTML string suitable for sending to a Telegram bot.
|
|
158
169
|
|
|
@@ -170,13 +181,15 @@ Represents a group of nomenclature discounts.
|
|
|
170
181
|
Defined in [nomenclature.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/src/oneCInteraction/nomenclature.py).
|
|
171
182
|
|
|
172
183
|
- `get(s_articleIn: str = "", s_nameIn: str = "", s_codeIn: str = "") -> Nomenclature | None`
|
|
173
|
-
Searches for and returns a product by its article, name, or code. Fetches retail
|
|
184
|
+
Searches for and returns a product by its article, name, or code. Fetches retail, wholesale, and purchase prices, stock balances by warehouses, characteristics, and the parent group's UUID (`s_parent_uuid`).
|
|
185
|
+
- `search(s_queryIn: str, s_searchByIn: str = "all") -> list`
|
|
186
|
+
Searches for nomenclature items by a query string matching the name, article, code, or all of them. Returns a list of `Nomenclature` objects (without full detailed price/stock breakdown, but containing basic fields).
|
|
174
187
|
- `get_images(c_productObjIn: Nomenclature, s_imageDirIn: str = None) -> list`
|
|
175
188
|
Downloads all attached images for a product from 1C. Saves them in the specified directory `s_imageDirIn` (defaults to `data/images`). Returns a list of the saved filenames (e.g., `["[uuid]_0.jpg"]`).
|
|
176
189
|
- `get_by_group(c_groupRefIn) -> list`
|
|
177
190
|
Batch fetches all products within a specific 1C group. Using optimized COM queries, this method minimizes DB requests and operates significantly faster than calling `get()` sequentially in a loop.
|
|
178
|
-
- `get_by_category(c_categoryIn
|
|
179
|
-
Batch fetches all products within a specific 1C category
|
|
191
|
+
- `get_by_category(c_categoryIn) -> list`
|
|
192
|
+
Batch fetches all products within a specific 1C category. `c_categoryIn` can be a COM reference object or a string representing the category name (searched within `Справочник.КатегорииОбъектов`).
|
|
180
193
|
|
|
181
194
|
---
|
|
182
195
|
|
|
@@ -196,9 +209,9 @@ Defined in [groups.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/
|
|
|
196
209
|
Defined in [categories.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/src/oneCInteraction/categories.py).
|
|
197
210
|
|
|
198
211
|
- `get(s_codeIn: str = "", s_nameIn: str = "") -> Category | None`
|
|
199
|
-
Finds a single Category by its code or name in the
|
|
212
|
+
Finds a single Category by its code or name in the `КатегорииОбъектов` (Object Categories) catalog.
|
|
200
213
|
- `create(s_nameIn: str) -> Category | None`
|
|
201
|
-
Creates a new Category with the specified name in
|
|
214
|
+
Creates a new Category with the specified name in `Справочник.КатегорииОбъектов` and returns it.
|
|
202
215
|
|
|
203
216
|
---
|
|
204
217
|
|
|
@@ -220,12 +233,12 @@ Defined in [orders.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/
|
|
|
220
233
|
- `push(c_orderObjIn: Order) -> str`
|
|
221
234
|
Creates a new `"Заказ покупателя"` (Buyer's Order) document in 1C.
|
|
222
235
|
- Automatically queries the warehouse, counteragent, and organization based on codes specified in the `Connection` object.
|
|
223
|
-
- Sets the
|
|
224
|
-
- Adds products from the order, queries the exact price for the specific characteristic selected, and computes totals.
|
|
236
|
+
- Sets the price type (defaulting to `"Розничная"` or using `s_price_type` from the order), document currency (Hryvnia, code `"980"`), and organization's primary bank account.
|
|
237
|
+
- Adds products from the order, queries/compares the exact price for the specific characteristic selected (using `s_price_type` to determine retail, wholesale, or purchase price), and computes totals.
|
|
225
238
|
- Attempts to post the document (`Posting`). If posting fails, it writes the document in draft/save mode (`Write`).
|
|
226
239
|
- Returns the number of the created document in 1C (or an empty string on error).
|
|
227
240
|
- `get(s_codeIn: str) -> Order | None`
|
|
228
|
-
Retrieves a buyer's order by its 1C document number and parses it into an `Order` object. The comment field is parsed to retrieve the Telegram ID.
|
|
241
|
+
Retrieves a buyer's order by its 1C document number and parses it into an `Order` object. The comment field is parsed to retrieve the Telegram ID, and the price type is retrieved.
|
|
229
242
|
- `get_today() -> list`
|
|
230
243
|
Returns a list of all today's orders created for the configured bot counteragent (filtered by current date and counteragent code).
|
|
231
244
|
- `update_info(c_orderObjIn: Order) -> bool`
|
|
@@ -259,7 +272,23 @@ Defined in [discounts.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionL
|
|
|
259
272
|
|
|
260
273
|
---
|
|
261
274
|
|
|
262
|
-
### 10.
|
|
275
|
+
### 10. Properties Manager `PropertiesManager` (`Connection.properties`)
|
|
276
|
+
Defined in [properties.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/src/oneCInteraction/properties.py).
|
|
277
|
+
|
|
278
|
+
- `write(self, c_productIn, s_propertyNameOrCodeIn: str, s_propertyValueIn: str) -> bool`
|
|
279
|
+
Writes or updates a single property value for a product (Nomenclature item).
|
|
280
|
+
- `write_batch(self, c_productIn, l_propertiesIn: list, b_forceIn: bool = False) -> list`
|
|
281
|
+
Writes/updates multiple properties for a product using a single 1C RecordSet. `l_propertiesIn` can be a list of `Property` objects or dicts `{"name": "...", "value": "..."}`.
|
|
282
|
+
- `get_assigned_properties(self, c_productIn) -> list`
|
|
283
|
+
Returns a list of `Property` objects assigned to the specified product.
|
|
284
|
+
- `delete(self, c_productIn, s_propertyNameOrCodeIn: str) -> bool`
|
|
285
|
+
Removes a specific property from a product in 1C register.
|
|
286
|
+
- `get_all_definitions(self) -> list`
|
|
287
|
+
Retrieves definitions of all active properties in 1C.
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
### 11. Logging (`log.py`)
|
|
263
292
|
Defined in [log.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/src/oneCInteraction/log.py).
|
|
264
293
|
|
|
265
294
|
All actions are logged automatically. The library resolves the root directory of the project that imported it and stores log files in the relative path `log/system/[calling_module_name].log`.
|
{onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction.egg-info/scm_file_list.json
RENAMED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": [
|
|
3
|
+
".gitignore",
|
|
3
4
|
"README.md",
|
|
4
|
-
"LICENSE",
|
|
5
5
|
"pyproject.toml",
|
|
6
|
-
"
|
|
7
|
-
"src/oneCInteraction/groups.py",
|
|
8
|
-
"src/oneCInteraction/__init__.py",
|
|
9
|
-
"src/oneCInteraction/orders.py",
|
|
6
|
+
"LICENSE",
|
|
10
7
|
"src/oneCInteraction/discounts.py",
|
|
11
|
-
"src/oneCInteraction/structures.py",
|
|
12
|
-
"src/oneCInteraction/log.py",
|
|
13
|
-
"src/oneCInteraction/customers.py",
|
|
14
|
-
"src/oneCInteraction/connection.py",
|
|
15
8
|
"src/oneCInteraction/categories.py",
|
|
16
9
|
"src/oneCInteraction/nomenclature.py",
|
|
10
|
+
"src/oneCInteraction/log.py",
|
|
11
|
+
"src/oneCInteraction/connection.py",
|
|
12
|
+
"src/oneCInteraction/structures.py",
|
|
13
|
+
"src/oneCInteraction/orders.py",
|
|
14
|
+
"src/oneCInteraction/groups.py",
|
|
17
15
|
"src/oneCInteraction/characteristics.py",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
16
|
+
"src/oneCInteraction/customers.py",
|
|
17
|
+
"src/oneCInteraction/__init__.py",
|
|
18
|
+
".github/workflows/publish.yml",
|
|
19
|
+
"tests/test_lib.py"
|
|
20
20
|
]
|
|
21
21
|
}
|
|
@@ -10,11 +10,17 @@ if hasattr(sys.stdout, 'reconfigure'):
|
|
|
10
10
|
|
|
11
11
|
try:
|
|
12
12
|
from datetime import datetime
|
|
13
|
-
from oneCInteraction import Connection, Customer, Order, OrderItem, Nomenclature, Variety, Price, Characteristic, Group, Category, DiscountGroup
|
|
13
|
+
from oneCInteraction import Connection, Customer, Order, OrderItem, Nomenclature, Variety, Price, Characteristic, Property, Group, Category, DiscountGroup
|
|
14
14
|
from oneCInteraction.log import log_sys, LOGS_DIR
|
|
15
15
|
|
|
16
16
|
print("Success: Imported Connection and all structures successfully from oneCInteraction!")
|
|
17
17
|
|
|
18
|
+
# Test Property structure
|
|
19
|
+
c_prop = Property("Колір", "Зелений")
|
|
20
|
+
assert c_prop.s_name == "Колір"
|
|
21
|
+
assert c_prop.s_value == "Зелений"
|
|
22
|
+
print("Success: Property instantiated.")
|
|
23
|
+
|
|
18
24
|
# Test instantiation of structures
|
|
19
25
|
c_cust = Customer(s_customerIdIn="123456789", s_customerNameIn="Ivan", s_customerSurnameIn="Ivanov", s_customerPhoneIn="+380991112233")
|
|
20
26
|
print("Success: Customer instantiated.")
|
|
@@ -80,8 +86,20 @@ try:
|
|
|
80
86
|
|
|
81
87
|
c_var = c_var_no_char
|
|
82
88
|
|
|
83
|
-
c_nom = Nomenclature(s_nameIn="Product 1", s_articleIn="ART001", l_varietyIn=[c_var])
|
|
84
|
-
|
|
89
|
+
c_nom = Nomenclature(s_nameIn="Product 1", s_articleIn="ART001", l_varietyIn=[c_var], l_propertiesIn=[c_prop])
|
|
90
|
+
assert c_nom.dt_last_arrival is None
|
|
91
|
+
assert len(c_nom.l_properties) == 1
|
|
92
|
+
assert c_nom.l_properties[0].s_name == "Колір"
|
|
93
|
+
|
|
94
|
+
dt_now = datetime.now()
|
|
95
|
+
c_nom_with_arrival = Nomenclature(
|
|
96
|
+
s_nameIn="Product 2",
|
|
97
|
+
s_articleIn="ART002",
|
|
98
|
+
l_varietyIn=[c_var],
|
|
99
|
+
dt_last_arrivalIn=dt_now
|
|
100
|
+
)
|
|
101
|
+
assert c_nom_with_arrival.dt_last_arrival == dt_now
|
|
102
|
+
print("Success: Nomenclature instantiated and verified with dt_last_arrival.")
|
|
85
103
|
|
|
86
104
|
c_cat = Category(s_categoryNameIn="Shoes", l_nomenclaturesIn=[c_nom])
|
|
87
105
|
print("Success: Category instantiated.")
|
|
@@ -111,7 +129,16 @@ try:
|
|
|
111
129
|
assert c_conn.categories is not None
|
|
112
130
|
assert c_conn.customers is not None
|
|
113
131
|
assert c_conn.discounts is not None
|
|
114
|
-
|
|
132
|
+
assert c_conn.properties is not None
|
|
133
|
+
print("Success: Checked all composition managers exist (including properties).")
|
|
134
|
+
|
|
135
|
+
# Test PropertiesManager when connection is not active
|
|
136
|
+
assert c_conn.properties.get_assigned_properties("ART001") == []
|
|
137
|
+
assert c_conn.properties.write("ART001", "Колір", "Зелений") is False
|
|
138
|
+
assert c_conn.properties.write_batch("ART001", [{"name": "Колір", "value": "Зелений"}]) == []
|
|
139
|
+
assert c_conn.properties.delete("ART001", "Колір") is False
|
|
140
|
+
assert c_conn.properties.get_all_definitions() == []
|
|
141
|
+
print("Success: PropertiesManager tested with no active connection.")
|
|
115
142
|
|
|
116
143
|
# Test DiscountsManager when connection is not active
|
|
117
144
|
discounts_res = c_conn.discounts.get_active_groups()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{onecinteraction-1.2.3 → onecinteraction-1.2.5}/src/oneCInteraction.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|