FrendsPlatform / FrendsTemplates

0 stars 0 forks source link

Import contacts from JSON into Odoo #79

Closed jefim closed 3 weeks ago

jefim commented 1 month ago
  1. Read the file from disk
  2. Go over all contact records
    1. For each record - check if its already present in Odoo (lets do email comparison)
    2. If partner exists - update it
    3. If partner does not exist - create it
  3. In the end shape report how many were updated and how many created.

Process parameters should include: the path of JSON on local disk and Odoo connection information.

In Odoo API contact is called a partner (res.partner), but would be no harm to double check this :)

Here is a sample JSON with approximate data that needs importing. Please ping if something is unclear.

[
  {
    "name": "ABC Corporation",
    "is_company": true,
    "street": "123 Elm Street",
    "city": "Springfield",
    "zip": "12345",
    "country": "USA",
    "phone": "+1234567890",
    "email": "info@abccorp.com",
    "website": "http://www.abccorp.com",
    "industry": "Manufacturing",
    "user": "Salesperson 1",
    "lang": "en_US",
    "tags": ["Important", "Client"],
    "company": "Main Company",
    "customer_rank": 3,
    "supplier_rank": 0,
    "opt_out": false,
    "comment": "Important client with high priority."
  },
  {
    "name": "Jane Doe",
    "is_company": false,
    "parent_company": "ABC Corporation",
    "street": "456 Oak Street",
    "city": "Springfield",
    "zip": "12345",
    "country": "USA",
    "phone": "+1234567891",
    "mobile": "+1234567892",
    "email": "jane.doe@example.com",
    "user": "Salesperson 2",
    "lang": "en_US",
    "tags": ["Contact"],
    "company": "Main Company",
    "customer_rank": 1,
    "supplier_rank": 0,
    "opt_out": true,
    "comment": "Preferred contact for ABC Corporation."
  },
  {
    "name": "XYZ Solutions",
    "is_company": true,
    "street": "789 Pine Street",
    "city": "Metropolis",
    "zip": "67890",
    "country": "USA",
    "phone": "+9876543210",
    "email": "contact@xyzsolutions.com",
    "website": "http://www.xyzsolutions.com",
    "industry": "IT Services",
    "user": "Salesperson 3",
    "lang": "fr_FR",
    "tags": ["Supplier"],
    "company": "Main Company",
    "customer_rank": 0,
    "supplier_rank": 2,
    "opt_out": false,
    "comment": "Supplier of IT services."
  },
  {
    "name": "John Smith",
    "is_company": false,
    "street": "101 Maple Street",
    "city": "Smalltown",
    "zip": "54321",
    "country": "USA",
    "phone": "+1122334455",
    "mobile": "+1122334456",
    "email": "john.smith@example.com",
    "user": "Salesperson 4",
    "lang": "en_US",
    "tags": ["Lead"],
    "company": "Main Company",
    "customer_rank": 1,
    "supplier_rank": 0,
    "opt_out": false,
    "comment": "Interested in new products."
  },
  {
    "name": "Acme Inc.",
    "is_company": true,
    "street": "202 Birch Street",
    "city": "Capital City",
    "zip": "13579",
    "country": "USA",
    "phone": "+1223344556",
    "email": "info@acmeinc.com",
    "website": "http://www.acmeinc.com",
    "industry": "Retail",
    "user": "Salesperson 5",
    "lang": "en_US",
    "tags": ["Client", "Retail"],
    "company": "Main Company",
    "customer_rank": 4,
    "supplier_rank": 1,
    "opt_out": false,
    "comment": "Long-term partner with consistent orders."
  },
  {
    "name": "Mary Johnson",
    "is_company": false,
    "street": "303 Cedar Street",
    "city": "Uptown",
    "zip": "24680",
    "country": "USA",
    "phone": "+2233445566",
    "mobile": "+2233445567",
    "email": "mary.johnson@example.com",
    "user": "Salesperson 6",
    "lang": "es_ES",
    "tags": ["Lead"],
    "company": "Main Company",
    "customer_rank": 1,
    "supplier_rank": 0,
    "opt_out": true,
    "comment": "Potential lead for sales."
  },
  {
    "name": "Tech Innovators",
    "is_company": true,
    "street": "404 Redwood Street",
    "city": "Innovation City",
    "zip": "11223",
    "country": "USA",
    "phone": "+3344556677",
    "email": "support@techinnovators.com",
    "website": "http://www.techinnovators.com",
    "industry": "Technology",
    "user": "Salesperson 7",
    "lang": "en_US",
    "tags": ["Innovative", "Supplier"],
    "company": "Main Company",
    "customer_rank": 2,
    "supplier_rank": 2,
    "opt_out": false,
    "comment": "Innovative tech supplier."
  },
  {
    "name": "Robert Brown",
    "is_company": false,
    "parent_company": "Tech Innovators",
    "street": "505 Aspen Street",
    "city": "Techville",
    "zip": "33445",
    "country": "USA",
    "phone": "+4455667788",
    "mobile": "+4455667789",
    "email": "robert.brown@example.com",
    "user": "Salesperson 8",
    "lang": "en_US",
    "tags": ["Technical Contact"],
    "company": "Main Company",
    "customer_rank": 1,
    "supplier_rank": 0,
    "opt_out": false,
    "comment": "Technical contact at Tech Innovators."
  },
  {
    "name": "Global Enterprises",
    "is_company": true,
    "street": "606 Fir Street",
    "city": "Global City",
    "zip": "55667",
    "country": "USA",
    "phone": "+5566778899",
    "email": "contact@globalenterprises.com",
    "website": "http://www.globalenterprises.com",
    "industry": "International Trade",
    "user": "Salesperson 9",
    "lang": "en_US",
    "tags": ["International", "Partner"],
    "company": "Main Company",
    "customer_rank": 5,
    "supplier_rank": 3,
    "opt_out": true,
    "comment": "Key international partner."
  },
  {
    "name": "Emily Davis",
    "is_company": false,
    "street": "707 Spruce Street",
    "city": "Oldtown",
    "zip": "66778",
    "country": "USA",
    "phone": "+6677889900",
    "mobile": "+6677889901",
    "email": "emily.davis@example.com",
    "user": "Salesperson 10",
    "lang": "en_US",
    "tags": ["Frequent Customer", "High Value"],
    "company": "Main Company",
    "customer_rank": 1,
    "supplier_rank": 0,
    "opt_out": false,
    "comment": "Frequent customer with high order value."
  }
]
sleekplan[bot] commented 1 month ago

This issue has been linked to frends-templates.sleekplan.app/feedback/162185. You can follow the discussion there!