Skip to content

Commit 106ec2c

Browse files
committed
Documentation update
1 parent ae2dee7 commit 106ec2c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ partner.update({'mobile': '12345678'})
5757
```
5858
- Search for Records
5959
```python
60-
partner_ids = odoo.env['res.partner'].search(domain=[('name', '=', 'Abigail Peterson')])
60+
partner_ids = odoo.env['res.partner'].search([('name', '=', 'Abigail Peterson')])
6161
print(partner_ids)
6262
#[50]
6363
```
@@ -77,8 +77,19 @@ print(new_partner_id)
7777
```
7878
- Update Records
7979
```python
80+
#These are the ways to update records
81+
partner.mobile = '+91 9746707744'
82+
partner.write({'mobile': '+91 9746707744'})
8083
odoo.env['res.partner'].write(ids=new_partner_id, values={'phone': '1234567890'})
8184
```
85+
- Update Relation fields (One2many or Many2many)
86+
```python
87+
from pyodoo_connect import Command
88+
partner.category_id = [Command.set([5,6])]
89+
partner.write({'category_id': [Command.link([4,3])]})
90+
odoo.env['res.partner'].write(ids=new_partner_id, values={'category_id': [Command.create({'name': 'New Tag'})]})
91+
#All functions of Command can be used (create, update, delete, unlink, link, clear, set)
92+
```
8293
- Delete Records
8394
```python
8495
odoo.env['res.partner'].unlink(ids=new_partner_id)
@@ -92,6 +103,11 @@ odoo.download_report(report_name='sale.report_saleorder', record_ids=[52], file_
92103
print(odoo.version)
93104
#17.0
94105
```
106+
- UID
107+
```python
108+
print(odoo.uid)
109+
#2
110+
```
95111
- User Context
96112
```python
97113
print(odoo.env.context)

pyodoo_connect/proxies.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ def __init__(self, model_proxy, record_id, method_name):
1414
self.method_name = method_name
1515

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

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

107108
def unlink(self, ids: list):

0 commit comments

Comments
 (0)