def _export(self, cr, uid, data, context): """Export (synchronize) the radiotv channels, categories, programs and channel_program_relations to Joomla PHP server.""" pool = pooler.get_pool(cr.dbname) web_ids = pool.get('radiotv.web').search(cr, uid, [('active','=',True)]) websites = pool.get('radiotv.web').browse(cr, uid, web_ids, context) if websites: server = xmlrpclib.ServerProxy(websites[0].url + "/tinyerp-synchro.php") # print websites[0].url # print server.get_table('radiotv_channel', {'id':'int', 'name':'string', 'description':'string'}) # deletes all many2many relations between channels and programs server.reset_channel_program(); (channel_new, channel_update, channel_delete) = export_table.export_table(self, cr, uid, data, context, server, 'channel', ['id', 'name', 'description', 'program_ids']) (category_new, category_update, category_delete) = export_table.export_table(self, cr, uid, data, context, server, 'category', ['id', 'name', 'description']) (program_new, program_update, program_delete) = export_table.export_table(self, cr, uid, data, context, server, 'program', ['id', 'name', 'introduction', 'description', 'state', 'team', 'email', 'category_id', 'production_year', 'classification', 'broadcast_language', 'original_language', 'production_type', 'editor', 'production_country_id', 'approx_duration',]) else: raise osv.except_osv(_('Error!'), _('No website defined!\nPlease create one.')) return { 'channel_new':channel_new, 'channel_update':channel_update, 'channel_delete':channel_delete, 'category_new':category_new, 'category_update':category_update, 'category_delete':category_delete, 'program_new':program_new, 'program_update':program_update, 'program_delete':program_delete, }
def _export(self, cr, uid, data, context): """Export (synchronize) the radiotv channels, categories, programs and channel_program_relations to Joomla PHP server.""" pool = pooler.get_pool(cr.dbname) web_ids = pool.get('radiotv.web').search(cr, uid, [('active', '=', True)]) websites = pool.get('radiotv.web').browse(cr, uid, web_ids, context) if websites: server = xmlrpclib.ServerProxy(websites[0].url + "/tinyerp-synchro.php") # print websites[0].url # print server.get_table('radiotv_channel', {'id':'int', 'name':'string', 'description':'string'}) # deletes all many2many relations between channels and programs server.reset_channel_program() (channel_new, channel_update, channel_delete) = export_table.export_table( self, cr, uid, data, context, server, 'channel', ['id', 'name', 'description', 'program_ids']) (category_new, category_update, category_delete) = export_table.export_table( self, cr, uid, data, context, server, 'category', ['id', 'name', 'description']) (program_new, program_update, program_delete) = export_table.export_table( self, cr, uid, data, context, server, 'program', [ 'id', 'name', 'introduction', 'description', 'state', 'team', 'email', 'category_id', 'production_year', 'classification', 'broadcast_language', 'original_language', 'production_type', 'editor', 'production_country_id', 'approx_duration', ]) else: raise osv.except_osv(_('Error!'), _('No website defined!\nPlease create one.')) return { 'channel_new': channel_new, 'channel_update': channel_update, 'channel_delete': channel_delete, 'category_new': category_new, 'category_update': category_update, 'category_delete': category_delete, 'program_new': program_new, 'program_update': program_update, 'program_delete': program_delete, }
def _export(self, cr, uid, data, context): """Export (synchronize) the radiotv broadcasts to Joomla PHP server.""" pool = pooler.get_pool(cr.dbname) web_ids = pool.get('radiotv.web').search(cr, uid, [('active','=',True)]) websites = pool.get('radiotv.web').browse(cr, uid, web_ids, context) if websites: server = xmlrpclib.ServerProxy(websites[0].url + "/tinyerp-synchro.php") form = data['form'] d_from = form.get('d_from', False) d_to = form.get('d_to', False) filter = [] filterphp = '' if d_from: filter.append(('dt_start', '>=', d_from + ' 00:00:00')) filterphp += " dt_start >= '" + d_from + " 00:00:00'" if d_to: filter.append(('dt_start', '<=', d_to + ' 23:59:59')) filterphp += " AND dt_start <= '" + d_to + " 23:59:59'" #print filterphp (broadcast_new, broadcast_update, broadcast_delete) = export_table.export_table(self, cr, uid, data, context, server, 'broadcast', ['id', 'dt_start', 'dt_end', 'channel_id', 'program_id', 'description', 'url'], filter, filterphp) else: raise osv.except_osv(_('Error!'), _('No website defined!\nPlease create one.')) return {'broadcast_new':broadcast_new, 'broadcast_update':broadcast_update, 'broadcast_delete':broadcast_delete,}
def _export(self, cr, uid, data, context): """Export (synchronize) the radiotv podcasts to Joomla PHP server.""" pool = pooler.get_pool(cr.dbname) web_ids = pool.get('radiotv.web').search(cr, uid, [('active','=',True)]) websites = pool.get('radiotv.web').browse(cr, uid, web_ids, context) if websites: server = xmlrpclib.ServerProxy(websites[0].url + "/tinyerp-synchro.php") form = data['form'] d_from = form.get('d_from', False) d_to = form.get('d_to', False) filter = [] filterphp = '' if d_from: filter.append(('pub_date', '>=', d_from + ' 00:00:00')) filterphp += " pub_date >= '" + d_from + " 00:00:00'" if d_to: filter.append(('pub_date', '<=', d_to + ' 23:59:59')) filterphp += " AND pub_date <= '" + d_to + " 23:59:59'" #print filterphp (podcast_new, podcast_update, podcast_delete) = export_table.export_table(self, cr, uid, data, context, server, 'podcast', ['id', 'name', 'file_name', 'description', 'broadcast_id', 'author', 'category', 'duration', 'keywords', 'subtitle', 'block', 'explicit', 'pub_date'], filter, filterphp) else: raise osv.except_osv(_('Error!'), _('No website defined!\nPlease create one.')) return {'podcast_new':podcast_new, 'podcast_update':podcast_update, 'podcast_delete':podcast_delete,}
def export_images(self, cr, uid, ids, data, context={}): """Export (synchronize) the training images to Joomla PHP server.""" web_ids = self.pool.get('training.joomla').search(cr, uid, [('active','=',True)]) websites = self.pool.get('training.joomla').browse(cr, uid, web_ids, context) if websites: for website in websites: location = website.location username = website.username password = website.password if not location[-1] == '/': location += '/' server = xmlrpclib.ServerProxy(location + "xmlrpc/index.php") # images filter = [] filterphp = '' (images_new, images_update, images_delete) = export_table.export_table(self, cr, uid, data, context, server, username, password, 'training.images', self._export_fields(), filter, filterphp) values = { 'state':'done', 'images_new':images_new, 'images_update':images_update, 'images_delete':images_delete, } self.write(cr, uid, ids, values) else: raise osv.except_osv(_('Error!'), _('No Joomla! location defined!\nPlease create one.')) return True
def export_courses(self, cr, uid, ids, data, context={}): """Export (synchronize) the training courses to Joomla PHP server.""" web_ids = self.pool.get('training.joomla').search( cr, uid, [('active', '=', True)]) websites = self.pool.get('training.joomla').browse( cr, uid, web_ids, context) if websites: for website in websites: location = website.location username = website.username password = website.password if not location[-1] == '/': location += '/' server = xmlrpclib.ServerProxy(location + "xmlrpc/index.php") # course filter = [] filterphp = '' if website.course_draft: filter.append(('state_course', '=', 'draft')) if website.course_pending: filter.append(('state_course', '=', 'pending')) if website.course_deprecated: filter.append(('state_course', '=', 'deprecated')) if website.course_validated: filter.append(('state_course', '=', 'validated')) for i in range(len(filter) - 1): filter.insert(0, '|') (course_new, course_update, course_delete) = export_table.export_table( self, cr, uid, data, context, server, username, password, 'training.course', self._export_fields(), filter, filterphp) values = { 'state': 'done', 'course_new': course_new, 'course_update': course_update, 'course_delete': course_delete, } self.write(cr, uid, ids, values) else: raise osv.except_osv( _('Error!'), _('No Joomla! location defined!\nPlease create one.')) return True
def export_courses(self, cr, uid, ids, data, context={}): """Export (synchronize) the training courses to Joomla PHP server.""" web_ids = self.pool.get('training.joomla').search(cr, uid, [('active','=',True)]) websites = self.pool.get('training.joomla').browse(cr, uid, web_ids, context) if websites: for website in websites: location = website.location username = website.username password = website.password if not location[-1] == '/': location += '/' server = xmlrpclib.ServerProxy(location + "xmlrpc/index.php") # course filter = [] filterphp = '' if website.course_draft: filter.append(('state_course','=','draft')) if website.course_pending: filter.append(('state_course','=','pending')) if website.course_deprecated: filter.append(('state_course','=','deprecated')) if website.course_validated: filter.append(('state_course','=','validated')) for i in range(len(filter)-1): filter.insert(0, '|') (course_new, course_update, course_delete) = export_table.export_table(self, cr, uid, data, context, server, username, password, 'training.course', self._export_fields(), filter, filterphp) values = { 'state':'done', 'course_new':course_new, 'course_update':course_update, 'course_delete':course_delete, } self.write(cr, uid, ids, values) else: raise osv.except_osv(_('Error!'), _('No Joomla! location defined!\nPlease create one.')) return True
def export_images(self, cr, uid, ids, data, context={}): """Export (synchronize) the training images to Joomla PHP server.""" web_ids = self.pool.get('training.joomla').search( cr, uid, [('active', '=', True)]) websites = self.pool.get('training.joomla').browse( cr, uid, web_ids, context) if websites: for website in websites: location = website.location username = website.username password = website.password if not location[-1] == '/': location += '/' server = xmlrpclib.ServerProxy(location + "xmlrpc/index.php") # images filter = [] filterphp = '' (images_new, images_update, images_delete) = export_table.export_table( self, cr, uid, data, context, server, username, password, 'training.images', self._export_fields(), filter, filterphp) values = { 'state': 'done', 'images_new': images_new, 'images_update': images_update, 'images_delete': images_delete, } self.write(cr, uid, ids, values) else: raise osv.except_osv( _('Error!'), _('No Joomla! location defined!\nPlease create one.')) return True
def _export(self, cr, uid, data, context): """Export (synchronize) the radiotv podcasts to Joomla PHP server.""" pool = pooler.get_pool(cr.dbname) web_ids = pool.get('radiotv.web').search(cr, uid, [('active', '=', True)]) websites = pool.get('radiotv.web').browse(cr, uid, web_ids, context) if websites: server = xmlrpclib.ServerProxy(websites[0].url + "/tinyerp-synchro.php") form = data['form'] d_from = form.get('d_from', False) d_to = form.get('d_to', False) filter = [] filterphp = '' if d_from: filter.append(('pub_date', '>=', d_from + ' 00:00:00')) filterphp += " pub_date >= '" + d_from + " 00:00:00'" if d_to: filter.append(('pub_date', '<=', d_to + ' 23:59:59')) filterphp += " AND pub_date <= '" + d_to + " 23:59:59'" #print filterphp (podcast_new, podcast_update, podcast_delete) = export_table.export_table( self, cr, uid, data, context, server, 'podcast', [ 'id', 'name', 'file_name', 'description', 'broadcast_id', 'author', 'category', 'duration', 'keywords', 'subtitle', 'block', 'explicit', 'pub_date' ], filter, filterphp) else: raise osv.except_osv('Error!', 'No website defined!\nPlease create one.') return { 'podcast_new': podcast_new, 'podcast_update': podcast_update, 'podcast_delete': podcast_delete, }
def _export(self, cr, uid, data, context): """Export (synchronize) the radiotv broadcasts to Joomla PHP server.""" pool = pooler.get_pool(cr.dbname) web_ids = pool.get('radiotv.web').search(cr, uid, [('active', '=', True)]) websites = pool.get('radiotv.web').browse(cr, uid, web_ids, context) if websites: server = xmlrpclib.ServerProxy(websites[0].url + "/tinyerp-synchro.php") form = data['form'] d_from = form.get('d_from', False) d_to = form.get('d_to', False) filter = [] filterphp = '' if d_from: filter.append(('dt_start', '>=', d_from + ' 00:00:00')) filterphp += " dt_start >= '" + d_from + " 00:00:00'" if d_to: filter.append(('dt_start', '<=', d_to + ' 23:59:59')) filterphp += " AND dt_start <= '" + d_to + " 23:59:59'" #print filterphp (broadcast_new, broadcast_update, broadcast_delete) = export_table.export_table( self, cr, uid, data, context, server, 'broadcast', [ 'id', 'dt_start', 'dt_end', 'channel_id', 'program_id', 'description', 'url' ], filter, filterphp) else: raise osv.except_osv('Error!', 'No website defined!\nPlease create one.') return { 'broadcast_new': broadcast_new, 'broadcast_update': broadcast_update, 'broadcast_delete': broadcast_delete, }
'description'] # Output to a CSV if 'csv' in export_types: export_csv(FIELDS, filtered_dinosaurs) # Output to an Excel file if 'xlsx' in export_types: export_excel(FIELDS, filtered_dinosaurs) # Output to a JSON file if 'json' in export_types: export_json(filtered_dinosaurs) # Ouput to the command line export_table(FIELDS, filtered_dinosaurs) # Print out single dinosaur if option provided def print_attribute(attribute): if not attribute: return 'N/A' if isinstance(attribute, set): return ', '.join(attribute).capitalize() else: return attribute if print_dino and dinosaur_to_print: dinosaur = dinosaur_to_print.pop() dinosaur_information = f"""
def export_sessions(self, cr, uid, ids, data, context={}): """Export (synchronize) the training sessions to Joomla PHP server.""" web_ids = self.pool.get('training.joomla').search(cr, uid, [('active','=',True)]) websites = self.pool.get('training.joomla').browse(cr, uid, web_ids, context) form = self.browse(cr, uid, ids[0]) d_from = form.d_from d_to = form.d_to if websites: for website in websites: location = website.location username = website.username password = website.password if not location[-1] == '/': location += '/' server = xmlrpclib.ServerProxy(location + "xmlrpc/index.php") # session filter = [] filterphp = '' if website.session_draft: filter.append(('state','=','draft')) if website.session_opened: filter.append(('state','=','opened')) if website.session_opened_confirmed: filter.append(('state','=','opened_confirmed')) if website.session_closed_confirmed: filter.append(('state','=','closed_confirmed')) if website.session_inprogress: filter.append(('state','=','inprogress')) if website.session_closed: filter.append(('state','=','opened_closed')) if website.session_cancelled: filter.append(('state','=','cancelled')) for i in range(len(filter)-1): filter.insert(0, '|') if d_from: filter.append(('date', '>=', d_from + ' 00:00:00')) filterphp += " date >= '" + d_from + " 00:00:00'" if d_to: filter.append(('date_end', '<=', d_to + ' 23:59:59')) filterphp += " AND date_end <= '" + d_to + " 23:59:59'" (session_new, session_update, session_delete) = export_table.export_table(self, cr, uid, data, context, server, username, password, 'training.session', self._export_fields(), filter, filterphp) values = { 'state':'done', 'session_new':session_new, 'session_update':session_update, 'session_delete':session_delete, } self.write(cr, uid, ids, values) else: raise osv.except_osv(_('Error!'), _('No Joomla! location defined!\nPlease create one.')) return True
def export_configurations(self, cr, uid, ids, data, context={}): """Export (synchronize) the training configurations to Joomla PHP server.""" web_ids = self.pool.get('training.joomla').search(cr, uid, [('active','=',True)]) websites = self.pool.get('training.joomla').browse(cr, uid, web_ids, context) if websites: for website in websites: location = website.location username = website.username password = website.password if not location[-1] == '/': location += '/' server = xmlrpclib.ServerProxy(location + "xmlrpc/index.php") # lang filter = [('active','=','1')] filterphp = '' (lang_new, lang_update, lang_delete) = export_table.export_table(self, cr, uid, data, context, server, username, password, 'res.lang', ['id', 'name', 'code'], filter, filterphp) # format filter = [('active','=','1')] filterphp = '' (format_new, format_update, format_delete) = export_table.export_table(self, cr, uid, data, context, server, username, password, 'training.offer.format', ['id', 'name'], filter, filterphp) # type filter = [] filterphp = '' (type_new, type_update, type_delete) = export_table.export_table(self, cr, uid, data, context, server, username, password, 'training.course_type', ['id', 'min_limit', 'max_limit', 'name', 'objective', 'description'], filter, filterphp) # theme filter = [] filterphp = '' (theme_new, theme_update, theme_delete) = export_table.export_table(self, cr, uid, data, context, server, username, password, 'training.course.theme', ['id', 'parent_id', 'name', 'description', 'priority'], filter, filterphp) # target audience filter = [] filterphp = '' (audience_new, audience_update, audience_delete) = export_table.export_table(self, cr, uid, data, context, server, username, password, 'training.offer.public.target', ['id', 'name', 'note'], filter, filterphp) # country filter = [] filterphp = '' (country_new, country_update, country_delete) = export_table.export_table(self, cr, uid, data, context, server, username, password, 'res.country', ['id', 'code', 'name'], filter, filterphp) # partner & address filter = [] filter_partners = [] filterphp = '' partners = website.partner_joomla_ids for partner in partners: filter_partners.append(('id','=',partner.id)) for address in partner.address: filter.append(('partner_id','=',partner.id)) for i in range(len(filter)-1): filter.insert(0, '|') for i in range(len(filter_partners)-1): filter_partners.insert(0, '|') (partner_new, partner_update, partner_delete) = export_table.export_table(self, cr, uid, data, context, server, username, password, 'res.partner', ['id', 'name'], filter_partners, filterphp) (address_new, address_update, address_delete) = export_table.export_table(self, cr, uid, data, context, server, username, password, 'res.partner.address', ['id', 'name', 'street', 'zip', 'city', 'phone', 'partner_id'], filter, filterphp) # product product_category_id = website.product_category_id filter = [('categ_id','=',product_category_id.id),('active','=',True)] filterphp = '' (product_new, product_update, product_delete) = export_table.export_table(self, cr, uid, data, context, server, username, password, 'product.product', ['id', 'name','list_price','deposit_price','default_code'], filter, filterphp) values = { 'state':'done', 'lang_new':lang_new, 'lang_update':lang_update, 'lang_delete':lang_delete, 'format_new':format_new, 'format_update':format_update, 'format_delete':format_delete, 'type_new':type_new, 'type_update':type_update, 'type_delete':type_delete, 'theme_new':theme_new, 'theme_update':theme_update, 'theme_delete':theme_delete, 'audience_new':audience_new, 'audience_update':audience_update, 'audience_delete':audience_delete, 'partner_new':partner_new, 'partner_update':partner_update, 'partner_delete':partner_delete, 'address_new':address_new, 'address_update':address_update, 'address_delete':address_delete, 'product_new':product_new, 'product_update':product_update, 'product_delete':product_delete, 'country_new':country_new, 'country_update':country_update, 'country_delete':country_delete, } self.write(cr, uid, ids, values) else: raise osv.except_osv(_('Error!'), _('No Joomla! location defined!\nPlease create one.')) return True
def export_configurations(self, cr, uid, ids, data, context={}): """Export (synchronize) the training configurations to Joomla PHP server.""" web_ids = self.pool.get('training.joomla').search( cr, uid, [('active', '=', True)]) websites = self.pool.get('training.joomla').browse( cr, uid, web_ids, context) if websites: for website in websites: location = website.location username = website.username password = website.password if not location[-1] == '/': location += '/' server = xmlrpclib.ServerProxy(location + "xmlrpc/index.php") # lang filter = [('active', '=', '1')] filterphp = '' (lang_new, lang_update, lang_delete) = export_table.export_table( self, cr, uid, data, context, server, username, password, 'res.lang', ['id', 'name', 'code'], filter, filterphp) # format filter = [('active', '=', '1')] filterphp = '' (format_new, format_update, format_delete) = export_table.export_table( self, cr, uid, data, context, server, username, password, 'training.offer.format', ['id', 'name'], filter, filterphp) # type filter = [] filterphp = '' (type_new, type_update, type_delete) = export_table.export_table( self, cr, uid, data, context, server, username, password, 'training.course_type', [ 'id', 'min_limit', 'max_limit', 'name', 'objective', 'description' ], filter, filterphp) # theme filter = [] filterphp = '' (theme_new, theme_update, theme_delete) = export_table.export_table( self, cr, uid, data, context, server, username, password, 'training.course.theme', ['id', 'parent_id', 'name', 'description', 'priority'], filter, filterphp) # target audience filter = [] filterphp = '' (audience_new, audience_update, audience_delete) = export_table.export_table( self, cr, uid, data, context, server, username, password, 'training.offer.public.target', ['id', 'name', 'note'], filter, filterphp) # country filter = [] filterphp = '' (country_new, country_update, country_delete) = export_table.export_table( self, cr, uid, data, context, server, username, password, 'res.country', ['id', 'code', 'name'], filter, filterphp) # partner & address filter = [] filter_partners = [] filterphp = '' partners = website.partner_joomla_ids for partner in partners: filter_partners.append(('id', '=', partner.id)) for address in partner.address: filter.append(('partner_id', '=', partner.id)) for i in range(len(filter) - 1): filter.insert(0, '|') for i in range(len(filter_partners) - 1): filter_partners.insert(0, '|') (partner_new, partner_update, partner_delete) = export_table.export_table( self, cr, uid, data, context, server, username, password, 'res.partner', ['id', 'name'], filter_partners, filterphp) (address_new, address_update, address_delete) = export_table.export_table( self, cr, uid, data, context, server, username, password, 'res.partner.address', [ 'id', 'name', 'street', 'zip', 'city', 'phone', 'partner_id' ], filter, filterphp) # product product_category_id = website.product_category_id filter = [('categ_id', '=', product_category_id.id), ('active', '=', True)] filterphp = '' (product_new, product_update, product_delete) = export_table.export_table( self, cr, uid, data, context, server, username, password, 'product.product', [ 'id', 'name', 'list_price', 'deposit_price', 'default_code' ], filter, filterphp) values = { 'state': 'done', 'lang_new': lang_new, 'lang_update': lang_update, 'lang_delete': lang_delete, 'format_new': format_new, 'format_update': format_update, 'format_delete': format_delete, 'type_new': type_new, 'type_update': type_update, 'type_delete': type_delete, 'theme_new': theme_new, 'theme_update': theme_update, 'theme_delete': theme_delete, 'audience_new': audience_new, 'audience_update': audience_update, 'audience_delete': audience_delete, 'partner_new': partner_new, 'partner_update': partner_update, 'partner_delete': partner_delete, 'address_new': address_new, 'address_update': address_update, 'address_delete': address_delete, 'product_new': product_new, 'product_update': product_update, 'product_delete': product_delete, 'country_new': country_new, 'country_update': country_update, 'country_delete': country_delete, } self.write(cr, uid, ids, values) else: raise osv.except_osv( _('Error!'), _('No Joomla! location defined!\nPlease create one.')) return True
def export_sessions(self, cr, uid, ids, data, context={}): """Export (synchronize) the training sessions to Joomla PHP server.""" web_ids = self.pool.get('training.joomla').search( cr, uid, [('active', '=', True)]) websites = self.pool.get('training.joomla').browse( cr, uid, web_ids, context) form = self.browse(cr, uid, ids[0]) d_from = form.d_from d_to = form.d_to if websites: for website in websites: location = website.location username = website.username password = website.password if not location[-1] == '/': location += '/' server = xmlrpclib.ServerProxy(location + "xmlrpc/index.php") # session filter = [] filterphp = '' if website.session_draft: filter.append(('state', '=', 'draft')) if website.session_opened: filter.append(('state', '=', 'opened')) if website.session_opened_confirmed: filter.append(('state', '=', 'opened_confirmed')) if website.session_closed_confirmed: filter.append(('state', '=', 'closed_confirmed')) if website.session_inprogress: filter.append(('state', '=', 'inprogress')) if website.session_closed: filter.append(('state', '=', 'opened_closed')) if website.session_cancelled: filter.append(('state', '=', 'cancelled')) for i in range(len(filter) - 1): filter.insert(0, '|') if d_from: filter.append(('date', '>=', d_from + ' 00:00:00')) filterphp += " date >= '" + d_from + " 00:00:00'" if d_to: filter.append(('date_end', '<=', d_to + ' 23:59:59')) filterphp += " AND date_end <= '" + d_to + " 23:59:59'" (session_new, session_update, session_delete) = export_table.export_table( self, cr, uid, data, context, server, username, password, 'training.session', self._export_fields(), filter, filterphp) values = { 'state': 'done', 'session_new': session_new, 'session_update': session_update, 'session_delete': session_delete, } self.write(cr, uid, ids, values) else: raise osv.except_osv( _('Error!'), _('No Joomla! location defined!\nPlease create one.')) return True