Skip to content

Commit

Permalink
Documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
fasilwdr committed May 9, 2024
1 parent ae2dee7 commit 106ec2c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ partner.update({'mobile': '12345678'})
```
- Search for Records
```python
partner_ids = odoo.env['res.partner'].search(domain=[('name', '=', 'Abigail Peterson')])
partner_ids = odoo.env['res.partner'].search([('name', '=', 'Abigail Peterson')])
print(partner_ids)
#[50]
```
Expand All @@ -77,8 +77,19 @@ print(new_partner_id)
```
- Update Records
```python
#These are the ways to update records
partner.mobile = '+91 9746707744'
partner.write({'mobile': '+91 9746707744'})
odoo.env['res.partner'].write(ids=new_partner_id, values={'phone': '1234567890'})
```
- Update Relation fields (One2many or Many2many)
```python
from pyodoo_connect import Command
partner.category_id = [Command.set([5,6])]
partner.write({'category_id': [Command.link([4,3])]})
odoo.env['res.partner'].write(ids=new_partner_id, values={'category_id': [Command.create({'name': 'New Tag'})]})
#All functions of Command can be used (create, update, delete, unlink, link, clear, set)
```
- Delete Records
```python
odoo.env['res.partner'].unlink(ids=new_partner_id)
Expand All @@ -92,6 +103,11 @@ odoo.download_report(report_name='sale.report_saleorder', record_ids=[52], file_
print(odoo.version)
#17.0
```
- UID
```python
print(odoo.uid)
#2
```
- User Context
```python
print(odoo.env.context)
Expand Down
3 changes: 2 additions & 1 deletion pyodoo_connect/proxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def __init__(self, model_proxy, record_id, method_name):
self.method_name = method_name

def __call__(self, *args, **kwargs):
if self.method_name == 'write':
self.method_name = 'update'
# If there are positional arguments, assume the first is a dictionary and reformat as needed
if args and isinstance(args[0], dict):
kwargs = {'values': args[0]} # Override kwargs with values from args
Expand Down Expand Up @@ -101,7 +103,6 @@ def search_read(self, domain: list, fields: list):
return self.odoo.call("object", "execute", self.model_name, 'search_read', domain, fields)

def write(self, ids: list, values: dict):
print(values)
return self.odoo.call("object", "execute", self.model_name, 'write', ids, values)

def unlink(self, ids: list):
Expand Down

0 comments on commit 106ec2c

Please sign in to comment.