Skip to content

Commit 71ab0eb

Browse files
author
Callum Dickinson
committed
Add support for fiscal positions
Add a new record types, managers and attributes for querying fiscal positions for partners. Fiscal positions are used to configure overrides for the product taxes a partner gets charged (e.g. for overseas customers).
1 parent 4d4f097 commit 71ab0eb

File tree

10 files changed

+539
-0
lines changed

10 files changed

+539
-0
lines changed

changelog.d/25.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for fiscal positions
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Fiscal Position Tax Mappings
2+
3+
*Added in version 0.2.4.*
4+
5+
This page documents how to use the manager and record objects
6+
for fiscal position tax mappings.
7+
8+
## Details
9+
10+
| Name | Value |
11+
|-----------------|--------------------------------|
12+
| Odoo Modules | Accounting |
13+
| Odoo Model Name | `account.fiscal.position.tax` |
14+
| Manager | `fiscal_position_tax_mappings` |
15+
| Record Type | `FiscalPositionTaxMapping` |
16+
17+
## Manager
18+
19+
The fiscal position tax mapping manager is available as the `fiscal_position_tax_mappings`
20+
attribute on the Odoo client object.
21+
22+
```python
23+
>>> from openstack_odooclient import Client as OdooClient
24+
>>> odoo_client = OdooClient(
25+
... hostname="localhost",
26+
... port=8069,
27+
... protocol="jsonrpc",
28+
... database="odoodb",
29+
... user="test-user",
30+
... password="<password>",
31+
... )
32+
>>> odoo_client.fiscal_position_tax_mappings.get(1234)
33+
FiscalPositionTaxMapping(record={'id': 1234, ...}, fields=None)
34+
```
35+
36+
For more information on how to use managers, refer to [Managers](index.md).
37+
38+
## Record
39+
40+
The fiscal position tax mapping manager returns `FiscalPositionTaxMapping` record objects.
41+
42+
To import the record class for type hinting purposes:
43+
44+
```python
45+
from openstack_odooclient import FiscalPositionTaxMapping
46+
```
47+
48+
The record class currently implements the following fields and methods.
49+
50+
For more information on attributes and methods common to all record types,
51+
see [Record Attributes and Methods](index.md#attributes-and-methods).
52+
53+
### `company_id`
54+
55+
```python
56+
company_id: int
57+
```
58+
59+
The ID for the [company](company.md) this fiscal position tax mapping
60+
is associated with.
61+
62+
### `company_name`
63+
64+
```python
65+
company_name: str
66+
```
67+
68+
The name of the [company](company.md) this fiscal position tax mapping
69+
is associated with.
70+
71+
### `company`
72+
73+
```python
74+
company: Company
75+
```
76+
77+
The [company](company.md) this fiscal position tax mapping
78+
is associated with.
79+
80+
This fetches the full record from Odoo once,
81+
and caches it for subsequent accesses.
82+
83+
### `position_id`
84+
85+
```python
86+
position_id: int
87+
```
88+
89+
The ID for the [fiscal position](fiscal-position.md) this mapping is part of.
90+
91+
### `position_name`
92+
93+
```python
94+
position_name: str
95+
```
96+
97+
The name of the [fiscal position](fiscal-position.md) this mapping is part of.
98+
99+
### `position`
100+
101+
```python
102+
position: FiscalPosition
103+
```
104+
105+
The [fiscal position](fiscal-position.md) this mapping is part of.
106+
107+
This fetches the full record from Odoo once,
108+
and caches it for subsequent accesses.
109+
110+
### `tax_src_id`
111+
112+
```python
113+
tax_src_id: int
114+
```
115+
116+
The ID of the [tax](tax.md) to be overridden on products.
117+
118+
### `tax_src_name`
119+
120+
```python
121+
tax_src_name: str
122+
```
123+
124+
The name of the [tax](tax.md) to be overridden on products.
125+
126+
### `tax_src`
127+
128+
```python
129+
tax_src: Tax
130+
```
131+
132+
The [tax](tax.md) to be overridden on products.
133+
134+
This fetches the full record from Odoo once,
135+
and caches it for subsequent accesses.
136+
137+
### `tax_dest_id`
138+
139+
```python
140+
tax_dest_id: int | None
141+
```
142+
143+
The ID of the [tax](tax.md) to override the source tax with, if set.
144+
145+
### `tax_dest_name`
146+
147+
```python
148+
tax_dest_name: str | None
149+
```
150+
151+
The name of the [tax](tax.md) to override the source tax with, if set.
152+
153+
### `tax_dest`
154+
155+
```python
156+
tax_dest: Tax | None
157+
```
158+
159+
The [tax](tax.md) to override the source tax with, if set.
160+
161+
This fetches the full record from Odoo once,
162+
and caches it for subsequent accesses.

docs/managers/fiscal-position.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Fiscal Positions
2+
3+
*Added in version 0.2.4.*
4+
5+
This page documents how to use the manager and record objects
6+
for fiscal positions.
7+
8+
## Details
9+
10+
| Name | Value |
11+
|-----------------|---------------------------|
12+
| Odoo Modules | Accounting, Point of Sale |
13+
| Odoo Model Name | `account.fiscal.position` |
14+
| Manager | `fiscal_positions` |
15+
| Record Type | `FiscalPosition` |
16+
17+
## Manager
18+
19+
The fiscal position manager is available as the `fiscal_positions`
20+
attribute on the Odoo client object.
21+
22+
```python
23+
>>> from openstack_odooclient import Client as OdooClient
24+
>>> odoo_client = OdooClient(
25+
... hostname="localhost",
26+
... port=8069,
27+
... protocol="jsonrpc",
28+
... database="odoodb",
29+
... user="test-user",
30+
... password="<password>",
31+
... )
32+
>>> odoo_client.fiscal_positions.get(1234)
33+
FiscalPosition(record={'id': 1234, ...}, fields=None)
34+
```
35+
36+
For more information on how to use managers, refer to [Managers](index.md).
37+
38+
## Record
39+
40+
The fiscal position manager returns `FiscalPosition` record objects.
41+
42+
To import the record class for type hinting purposes:
43+
44+
```python
45+
from openstack_odooclient import FiscalPosition
46+
```
47+
48+
The record class currently implements the following fields and methods.
49+
50+
For more information on attributes and methods common to all record types,
51+
see [Record Attributes and Methods](index.md#attributes-and-methods).
52+
53+
### `active`
54+
55+
```python
56+
active: bool
57+
```
58+
59+
Whether or not this fiscal position is active (enabled).
60+
61+
### `company_id`
62+
63+
```python
64+
company_id: int
65+
```
66+
67+
The ID for the [company](company.md) this fiscal position is associated with.
68+
69+
### `company_name`
70+
71+
```python
72+
company_name: str
73+
```
74+
75+
The name of the [company](company.md) this fiscal position is associated with.
76+
77+
### `company`
78+
79+
```python
80+
company: Company
81+
```
82+
83+
The [company](company.md) this fiscal position is associated with.
84+
85+
This fetches the full record from Odoo once,
86+
and caches it for subsequent accesses.
87+
88+
### `name`
89+
90+
```python
91+
name: str
92+
```
93+
94+
The name of the fiscal position.
95+
96+
Not guaranteed to be unique.
97+
98+
### `tax_ids`
99+
100+
```python
101+
tax_ids: list[int]
102+
```
103+
104+
The list of IDs for the [tax mappings](fiscal-position-tax-mapping.md) that will be applied
105+
to sale orders and invoices for partners using this
106+
fiscal position.
107+
108+
### `taxes`
109+
110+
```python
111+
taxes: list[FiscalPositionTaxMapping]
112+
```
113+
114+
The list of [tax mappings](fiscal-position-tax-mapping.md) that will be applied
115+
to sale orders and invoices for partners using this
116+
fiscal position.
117+
118+
This fetches the full records from Odoo once,
119+
and caches them for subsequent accesses.

docs/managers/partner.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,39 @@ if it has a parent.
307307
This fetches the full record from Odoo once,
308308
and caches it for subsequent accesses.
309309

310+
### `property_account_position_id`
311+
312+
```python
313+
property_account_position_id: int | None
314+
```
315+
316+
The ID for the [fiscal position](fiscal-position.md) this partner uses, if it uses one.
317+
318+
*Added in version 0.2.4.*
319+
320+
### `property_account_position_name`
321+
322+
```python
323+
property_account_position_name: str | None
324+
```
325+
326+
The name of the [fiscal position](fiscal-position.md) this partner uses, if it uses one.
327+
328+
*Added in version 0.2.4.*
329+
330+
### `property_account_position`
331+
332+
```python
333+
property_account_position: FiscalPosition | None
334+
```
335+
336+
The [fiscal position](fiscal-position.md) this partner uses, if it uses one.
337+
338+
This fetches the full record from Odoo once,
339+
and caches it for subsequent accesses.
340+
341+
*Added in version 0.2.4.*
342+
310343
### `property_product_pricelist_id`
311344

312345
```python

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ nav:
4141
- managers/credit-transaction.md
4242
- managers/currency.md
4343
- managers/customer-group.md
44+
- managers/fiscal-position.md
45+
- managers/fiscal-position-tax-mapping.md
4446
- managers/grant.md
4547
- managers/grant-type.md
4648
- managers/partner.md

openstack_odooclient/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
from .managers.credit_type import CreditType, CreditTypeManager
4545
from .managers.currency import Currency, CurrencyManager
4646
from .managers.customer_group import CustomerGroup, CustomerGroupManager
47+
from .managers.fiscal_position import FiscalPosition, FiscalPositionManager
48+
from .managers.fiscal_position_tax_mapping import (
49+
FiscalPositionTaxMapping,
50+
FiscalPositionTaxMappingManager,
51+
)
4752
from .managers.grant import Grant, GrantManager
4853
from .managers.grant_type import GrantType, GrantTypeManager
4954
from .managers.partner import Partner, PartnerManager
@@ -108,6 +113,10 @@
108113
"CustomerGroup",
109114
"CustomerGroupManager",
110115
"FieldAlias",
116+
"FiscalPosition",
117+
"FiscalPositionManager",
118+
"FiscalPositionTaxMapping",
119+
"FiscalPositionTaxMappingManager",
111120
"Grant",
112121
"GrantManager",
113122
"GrantType",

openstack_odooclient/client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
from .managers.credit_type import CreditTypeManager
2626
from .managers.currency import CurrencyManager
2727
from .managers.customer_group import CustomerGroupManager
28+
from .managers.fiscal_position import FiscalPositionManager
29+
from .managers.fiscal_position_tax_mapping import (
30+
FiscalPositionTaxMappingManager,
31+
)
2832
from .managers.grant import GrantManager
2933
from .managers.grant_type import GrantTypeManager
3034
from .managers.partner import PartnerManager
@@ -112,6 +116,12 @@ class Client(ClientBase):
112116
customer_groups: CustomerGroupManager
113117
"""OpenStack customer group manager."""
114118

119+
fiscal_positions: FiscalPositionManager
120+
"""Fiscal position manager."""
121+
122+
fiscal_position_tax_mappings: FiscalPositionTaxMappingManager
123+
"""Fiscal position tax mapping manager."""
124+
115125
grants: GrantManager
116126
"""OpenStack grant manager."""
117127

0 commit comments

Comments
 (0)