Metadata-Version: 2.1
Name: pyodoo_connect
Version: 0.1.2
Summary: A Python package to interact with Odoo via JSON-RPC.
Home-page: https://github.com/fasilwdr/pyodoo_connector
Author: Fasil
Author-email: Fasil <fasilwdr@hotmail.com>
License: MIT License
        
        Copyright (c) [2024] [Fasil]
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE


# PyOdoo Connector

PyOdoo Connector is a Python package providing a convenient way to interact with Odoo platforms via JSON-RPC. It simplifies operations like logging in, executing commands, and managing records in an Odoo database.

## Features

- **Session Management**: Handles login and session management automatically.
- **CRUD Operations**: Easy-to-use functions for creating, reading, updating, and deleting records.
- **Method Execution**: Supports calling custom methods defined in Odoo models.
- **Error Handling**: Implements error handling for HTTP and URL request errors.
- **Report Downloading**: Allows downloading reports from Odoo in PDF form.

## Installation

Install Odoo Connector using pip:

```bash
pip install pyodoo_connect
```

### Prerequisites

- Python 3.6 or higher.
- Access to an Odoo instance with the JSON-RPC interface enabled.

Ensure you have the necessary permissions to interact with the Odoo server as some operations might require administrative access.

## Configuration

Before using this module, configure the connection parameters to match your Odoo instance settings:

1. **URL**: The URL of your Odoo server.
2. **Database**: The database name.
3. **Username**: Your Odoo username.
4. **Password**: Your Odoo password.

## Usage

Here is a simple example to show how you can use Odoo Connector to interact with an Odoo instance:
### Initializing the Connection
```python
from pyodoo_connect import Odoo
odoo = Odoo('https://example-odoo.com/', 'your-db', 'your-username', 'your-password')
```
### Basic Operations
- Get a Partner Record
```python
partner = odoo.env['res.partner'].browse(9)
partner.name = 'New Partner Name'
```

- Execute a Method on a Record
```python
partner.action_archive()
partner.update({'mobile': '12345678'})
```
- Search for Records
```python
partner_ids = odoo.env['res.partner'].search(domain=[('name', '=', 'Abigail Peterson')])
print(partner_ids)
#[50]
```
- Read Records
```python
print(partner.name)
records = odoo.env['res.partner'].read(ids=partner_ids, fields=['name', 'email'])
print(records)
#Wood Corner
#[{'id': 50, 'name': 'Abigail Peterson', 'email': 'abigail.peterson39@example.com'}]
```
- Create a New Record
```python
new_partner_id = odoo.env['res.partner'].create({'name': 'New Partner', 'email': 'new@partner.com', 'is_company': True})
print(new_partner_id)
#100
```
- Update Records
```python
odoo.env['res.partner'].write(ids=new_partner_id, values={'phone': '1234567890'})
```
- Delete Records
```python
odoo.env['res.partner'].unlink(ids=new_partner_id)
```
- Download a QWeb Report
```python
odoo.download_report(report_name='sale.report_saleorder', record_ids=[52], file_name='Sales Report')
```
- Version
```python
print(odoo.version)
#17.0
```
- User Context
```python
print(odoo.env.context)
#{'lang': 'en_US', 'tz': 'Europe/Brussels', 'uid': 2}
```
- User Info
```python
print(odoo.env.user_info)
#{'uid': 2, 'is_admin': True, 'name': 'Mitchell Admin', 'username': 'admin', 'partner_id': 3}
```
- Settings
```python
print(odoo.env.settings)
#{'web_base_url': 'https://demo.odoo.com', 'localization': {'lang': 'en_US', 'tz': 'Europe/Brussels'}, 'company_details': {'current_company': 1, 'allowed_companies': {'2': {'id': 2, 'name': 'My Company (Chicago)', 'sequence': 10, 'child_ids': [], 'parent_id': False, 'timesheet_uom_id': 4, 'timesheet_uom_factor': 1.0}, '1': {'id': 1, 'name': 'My Company (San Francisco)', 'sequence': 0, 'child_ids': [], 'parent_id': False, 'timesheet_uom_id': 4, 'timesheet_uom_factor': 1.0}}, 'disallowed_ancestor_companies': {}}}
```

## Contributing
Contributions are welcome! Please feel free to submit pull requests, report bugs, or suggest features.

## License
This project is licensed under the MIT License - see the LICENSE file for details.
