# Command line arguments parser = argparse.ArgumentParser(description='Regenerate the fractions HTML for development buildings.') parser.add_argument('-c', '--config', required=True, help='Configuration file', metavar='CONFIGFILE') parser.add_argument('-l', '--logger-config', required=True, help='Logger dict configuration file', metavar='LOGGERDICTCONFIGFILE') parser_result = parser.parse_args() arguments = vars(parser_result) # Configuration files config_filename = arguments['config'] logger_config_filename = arguments['logger_config'] # Load logging configuration source_file_loader = SourceFileLoader('logsettings', logger_config_filename) logsettings = source_file_loader.load_module() logging.config.dictConfig(logsettings.LOGGING) # Load configuration from file config = configparser.ConfigParser(interpolation=None) with io.open(config_filename) as config_file_handle: config.read_file(config_file_handle) # Initialize odoo connector common_proxy = xmlrpc.client.Server('{}/xmlrpc/2/common'.format(config['odoo']['api_url'])) models_proxy = xmlrpc.client.Server('{}/xmlrpc/2/object'.format(config['odoo']['api_url'])) odoo = Connector(common_proxy, models_proxy, config['odoo']['database'], config['odoo']['username'], config['odoo']['password']) # Go odoo.regenerate_fractions_html()
# Load logging configuration source_file_loader = SourceFileLoader("logsettings", logger_config_filename) logsettings = source_file_loader.load_module() logging.config.dictConfig(logsettings.LOGGING) logger = logging.getLogger(__name__) # Load configuration from file config = configparser.ConfigParser(interpolation=None) with io.open(config_filename) as config_file_handle: config.read_file(config_file_handle) # Initialize odoo connector common_proxy = xmlrpc.client.Server("{}/xmlrpc/2/common".format(config["odoo"]["api_url"])) models_proxy = xmlrpc.client.Server("{}/xmlrpc/2/object".format(config["odoo"]["api_url"])) odoo = Connector( common_proxy, models_proxy, config["odoo"]["database"], config["odoo"]["username"], config["odoo"]["password"] ) if not parser_result.delete: logger.warn("--delete option not passed so the contacts will not actually be deleted") logger.info("Retrieving the list of contacts to delete") contacts_to_delete = odoo.contacts_to_delete() total = len(contacts_to_delete) logger.info("Total to delete: %i", total) # count = 0 for counter, contact in enumerate(odoo.get_partners(contacts_to_delete)): logger.info("Deleting %i of %i: %s", counter + 1, total, contact) if parser_result.delete: odoo.delete_contact(contact["id"])
# Command line arguments parser = argparse.ArgumentParser(description='Regenerate the HTML of products.') parser.add_argument('-c', '--config', required=True, help='Configuration file', metavar='CONFIGFILE') parser.add_argument('-l', '--logger-config', required=True, help='Logger dict configuration file', metavar='LOGGERDICTCONFIGFILE') parser_result = parser.parse_args() arguments = vars(parser_result) # Configuration files config_filename = arguments['config'] logger_config_filename = arguments['logger_config'] # Load logging configuration source_file_loader = SourceFileLoader('logsettings', logger_config_filename) logsettings = source_file_loader.load_module() logging.config.dictConfig(logsettings.LOGGING) # Load configuration from file config = configparser.ConfigParser(interpolation=None) with io.open(config_filename) as config_file_handle: config.read_file(config_file_handle) # Initialize odoo connector common_proxy = xmlrpc.client.Server('{}/xmlrpc/2/common'.format(config['odoo']['api_url'])) models_proxy = xmlrpc.client.Server('{}/xmlrpc/2/object'.format(config['odoo']['api_url'])) odoo = Connector(common_proxy, models_proxy, config['odoo']['database'], config['odoo']['username'], config['odoo']['password']) # Go odoo.regenerate_html()
# Command line arguments parser = argparse.ArgumentParser(description='Regenerate the similar products HTML for all the products.') parser.add_argument('-c', '--config', required=True, help='Configuration file', metavar='CONFIGFILE') parser.add_argument('-l', '--logger-config', required=True, help='Logger dict configuration file', metavar='LOGGERDICTCONFIGFILE') parser_result = parser.parse_args() arguments = vars(parser_result) # Configuration files config_filename = arguments['config'] logger_config_filename = arguments['logger_config'] # Load logging configuration source_file_loader = SourceFileLoader('logsettings', logger_config_filename) logsettings = source_file_loader.load_module() logging.config.dictConfig(logsettings.LOGGING) # Load configuration from file config = configparser.ConfigParser(interpolation=None) with io.open(config_filename) as config_file_handle: config.read_file(config_file_handle) # Initialize odoo connector common_proxy = xmlrpc.client.Server('{}/xmlrpc/2/common'.format(config['odoo']['api_url'])) models_proxy = xmlrpc.client.Server('{}/xmlrpc/2/object'.format(config['odoo']['api_url'])) odoo = Connector(common_proxy, models_proxy, config['odoo']['database'], config['odoo']['username'], config['odoo']['password']) # Go ids = odoo.regenerate_similar_products_html()