OBS-URL: https://build.opensuse.org/package/show/Application:ERP:GNUHealth:Factory/gnuhealth?expand=0&rev=130
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# SPDX-FileCopyrightText: 2008-2025 Luis Falcón <falcon@gnuhealth.org>
|
||||
# SPDX-FileCopyrightText: 2011-2025 GNU Solidario <health@gnusolidario.org>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#########################################################################
|
||||
# Hospital Management Information System (HMIS) component of the #
|
||||
# GNU Health project #
|
||||
# https://www.gnuhealth.org #
|
||||
#########################################################################
|
||||
# sync_fs_records.oy #
|
||||
# Script to automate datasets synchronization #
|
||||
#########################################################################
|
||||
import argparse
|
||||
|
||||
from proteus import Model
|
||||
from proteus import config as pconfig
|
||||
|
||||
|
||||
def main():
|
||||
options = parse_options()
|
||||
connect_service(options)
|
||||
update_data()
|
||||
|
||||
|
||||
def parse_options():
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument('-H', '--hostname', default='localhost',
|
||||
help="Hostname of GNU Health Server, "
|
||||
"default=localhost.")
|
||||
parser.add_argument('-p', '--port', default='8000',
|
||||
help="Port of GNU Health Service, default=8000.")
|
||||
parser.add_argument('-u', '--user', default='admin',
|
||||
help="User name of GNU Health, default=admin.")
|
||||
parser.add_argument('-P', '--passwd', required=True,
|
||||
help="Password of GNU Health.")
|
||||
parser.add_argument('-d', '--database', required=True,
|
||||
help="Database name of GNU Health.")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def connect_service(options):
|
||||
hostname = options.hostname
|
||||
port = options.port
|
||||
user = options.user
|
||||
passwd = options.passwd
|
||||
dbname = options.database
|
||||
|
||||
health_server = 'http://' + user + ':' + passwd + \
|
||||
'@' + hostname + ':' + port + '/' + dbname + '/'
|
||||
|
||||
print("## Connecting to GNU Health Server ...")
|
||||
pconfig.set_xmlrpc(health_server)
|
||||
print("## Connected!\n")
|
||||
|
||||
|
||||
def update_data():
|
||||
''' Search for records that are out of sync with the XML
|
||||
datafile in the filesystem and updates them with the contents
|
||||
of file
|
||||
'''
|
||||
ModelData = Model.get('ir.model.data')
|
||||
records = ModelData.find([('out_of_sync', '=', True)])
|
||||
print(f"Number of records to sync: {len(records)}")
|
||||
for record in records:
|
||||
print(f"Syncing {record.model} - resource id: {record.db_id}")
|
||||
try:
|
||||
record.click('sync')
|
||||
except BaseException:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Reference in New Issue
Block a user