def __init__(self, host, dbname, password, fileName, display=False): super(MyCustomerManager, self).__init__(host, dbname, password) c = CsvParser(fileName) for row, count in c.rows(): raw_data = { 'name': row['name'], 'street': row['street'], 'zip': row['zip'], 'city': row['city'], 'phone': row['phone'], 'mobile': row['mobile'], 'fax': row['fax'], 'email': row['email'], 'website': row['website'], 'customer': self.booleanFromString(row['customer']), 'is_company': self.booleanFromString(row['is_company']), } many2one_data = { 'title': row['title'], 'country': row['country'], } ID = self.insert(raw_data, many2one_data, row['ref']) if display == True: print(str(count) + ' --- ID: ' + str(ID))
def run(self, fileName): c = CsvParser(fileName) for row, count in c.rows(): data = {} for key in self.fieldsNames: value = self.fieldsNames[key] if type(value) == dict: data[key] = value['records'][row[value['fieldName']]] else: data[key] = row[value] ref = row['ref'] ID = self.insertOrUpdate(ref,'res.partner', data, self.existing_partners_records) if __name__ == '__main__': print(str(count) + ' --- ID: ' + str(ID))
def __init__(self, host, dbname, password, fileName, display=False): super(MyStockManager, self).__init__(host, dbname, password) data = self.all_records('product.product', ['default_code', 'name_template']) product_records = self.list_to_dict(data, 'default_code', 'name_template') c = CsvParser(fileName) for row, count in c.rows(): kwargs = { 'product_ref': row['ref'], 'product_qty': row['qty'], 'product_uom': row['uom'], 'source': row['source'], 'destination': row['destination'], 'state': 'done', 'name': '[' + row['ref'] + '] ' + product_records[row['ref']], } ID = self.update_stock(**kwargs) if display == True: print(str(count) + ' --- ID: ' + str(ID))
def __init__(self, host, dbname, password, fileName, display=False): super(ProductManager, self).__init__(host, dbname, password) existing_prod_tmpl_records = self.prepare_ir_model_data('product.template') existing_prod_prod_records = self.prepare_ir_model_data('product.product') category_records = self.prepare_many2one('product.category') fields_tmpl = ['name', 'description', 'weight_net', 'standard_price', 'list_price', 'type'] taxes_id = self.search('account.tax', [('description', '=', '20')]) supplier_taxes_id = self.search('account.tax', [('description', '=', 'ACH-20')]) c = CsvParser(fileName, delimiter=';') for row, count in c.rows(): # product_template data_tmpl = {field: row[field] for field in fields_tmpl} data_tmpl['sale_ok'] = True data_tmpl['purchase_ok'] = True data_tmpl['supply_method'] = 'buy' data_tmpl['procure_method'] = 'make_to_stock' data_tmpl['categ_id'] = category_records[row['category']] ref = row['ref'] product_tmpl_id = self.insertOrUpdate( ref + '_product_template','product.template', data_tmpl, existing_prod_tmpl_records) # product_product data_product = { 'default_code': ref, 'name_template': row['name'], 'active': True, 'product_tmpl_id': product_tmpl_id, 'taxes_id': [(6, 0, taxes_id)], 'supplier_taxes_id': [(6, 0, supplier_taxes_id)], } product_product_id = self.insertOrUpdate( ref, 'product.product', data_product, existing_prod_prod_records) if display == True: print(str(count) + ' --- ID: ' + str(product_product_id))