Answer the question
In order to leave comments, you need to log in
How to get the value of the Document field in 1C query if this field has a reference type?
There is the following Python code that clings to the 1C database via a COM connection:
#coding=cp1251
import pythoncom
import win32com.client
V83_CONN_STRING = 'File="C:\\Users\\user\\Documents\\InfoBase\\";Usr="Иванов Иван";Pwd="123456";'
pythoncom.CoInitialize()
V83 = win32com.client.Dispatch("V83.COMConnector").Connect(V83_CONN_STRING)
q = '''
ВЫБРАТЬ
ДатаЗапуска КАК DATESTART,
Комментарий КАК KOMMENT,
Организация КАК ORG
ИЗ
Документ.ЗаказНаПроизводство
ГДЕ ДатаЗапуска МЕЖДУ ДАТАВРЕМЯ(2018, 12, 1, 0, 0, 0) И ДАТАВРЕМЯ(2018, 12, 5, 0, 0, 0)
'''
query = V83.NewObject("Query", q)
sel = query.Execute().Choose()
while sel.next():
print(sel.DATESTART)
print(sel.KOMMENT)
print(sel.ORG)
Answer the question
In order to leave comments, you need to log in
Organization is of type DirectoryReference. Organizations and the corresponding print() outputs >.
Above, Konstantin wrote everything correctly. The organization from ProductionOrder is not a string, but an internal reference type, which has no match in python, and therefore standard output cannot cope with this value.
I suspect that it will be a COM object. If my hypothesis is correct, then it should work:print(sel.ORG.Description)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question