Skip to content

Commit 35a9a0b

Browse files
author
Callum Dickinson
committed
Add fiscal position record type
Add a new `FiscalPosition` record type, and an accompanying `fiscal_positions` record manager. Other record types have had model refs for fiscal positions added.
1 parent 4d4f097 commit 35a9a0b

6 files changed

Lines changed: 260 additions & 0 deletions

File tree

docs/managers/fiscal-position.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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 customer group 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 customer group 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+
54+
### `active`
55+
56+
```python
57+
active: bool
58+
```
59+
60+
Whether or not this fiscal position is active (enabled).
61+
62+
### `company_id`
63+
64+
```python
65+
company_id: Annotated[int, ModelRef("company_id", Company)]
66+
```
67+
68+
The ID for the company this fiscal position is associated with.
69+
70+
### `company_name`
71+
72+
```python
73+
company_name: Annotated[str, ModelRef("company_id", Company)]
74+
```
75+
76+
The name of the company this fiscal position is associated with.
77+
78+
### `company`
79+
80+
```python
81+
company: Annotated[Company, ModelRef("company_id", Company)]
82+
```
83+
84+
The company this fiscal position is associated with.
85+
86+
This fetches the full record from Odoo once,
87+
and caches it for subsequent accesses.
88+
89+
### `name`
90+
91+
```python
92+
name: str
93+
```
94+
95+
The name of the fiscal position.
96+
97+
Not guaranteed to be unique.
98+
99+
### `tax_ids`
100+
101+
```python
102+
tax_ids: Annotated[list[int], ModelRef("tax_ids", Tax)]
103+
```
104+
105+
The list of IDs for the taxes that will be applied
106+
to sale orders and invoices for partners using this
107+
fiscal position.
108+
109+
### `taxes`
110+
111+
```python
112+
taxes: Annotated[list[Tax], ModelRef("tax_ids", Tax)]
113+
```
114+
115+
The list of taxes that will be applied
116+
to sale orders and invoices for partners using this
117+
fiscal position.
118+
119+
This fetches the full records from Odoo once,
120+
and caches them for subsequent accesses.

docs/managers/partner.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,39 @@ email: str
9191

9292
Main e-mail address for the partner.
9393

94+
### `fiscal_position_id`
95+
96+
```python
97+
fiscal_position_id: int | None
98+
```
99+
100+
The ID for the [fiscal position](fiscal-position.md) this partner uses, if it uses one.
101+
102+
*Added in version 0.2.4.*
103+
104+
### `fiscal_position_name`
105+
106+
```python
107+
fiscal_position_name: str | None
108+
```
109+
110+
The name of the [fiscal position](fiscal-position.md) this partner uses, if it uses one.
111+
112+
*Added in version 0.2.4.*
113+
114+
### `fiscal_position`
115+
116+
```python
117+
fiscal_position: FiscalPosition | None
118+
```
119+
120+
The [fiscal position](fiscal-position.md) this partner uses, if it uses one.
121+
122+
This fetches the full record from Odoo once,
123+
and caches it for subsequent accesses.
124+
125+
*Added in version 0.2.4.*
126+
94127
### `name`
95128

96129
```python

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ nav:
4141
- managers/credit-transaction.md
4242
- managers/currency.md
4343
- managers/customer-group.md
44+
- managers/fiscal-position.md
4445
- managers/grant.md
4546
- managers/grant-type.md
4647
- managers/partner.md

openstack_odooclient/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
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
2829
from .managers.grant import GrantManager
2930
from .managers.grant_type import GrantTypeManager
3031
from .managers.partner import PartnerManager
@@ -112,6 +113,9 @@ class Client(ClientBase):
112113
customer_groups: CustomerGroupManager
113114
"""OpenStack customer group manager."""
114115

116+
fiscal_position: FiscalPositionManager
117+
"""Fiscal position manager."""
118+
115119
grants: GrantManager
116120
"""OpenStack grant manager."""
117121

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright (C) 2026 Catalyst Cloud Limited
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12+
# implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
from __future__ import annotations
17+
18+
from typing import Annotated
19+
20+
from ..base.record.base import RecordBase
21+
from ..base.record.types import ModelRef
22+
from ..base.record_manager.base import RecordManagerBase
23+
24+
25+
class FiscalPosition(RecordBase["FiscalPositionManager"]):
26+
active: bool
27+
"""Whether or not this fiscal position is active (enabled)."""
28+
29+
company_id: Annotated[int, ModelRef("company_id", Company)]
30+
"""The ID for the company this fiscal position is associated with."""
31+
32+
company_name: Annotated[str, ModelRef("company_id", Company)]
33+
"""The name of the company this fiscal position is associated with."""
34+
35+
company: Annotated[Company, ModelRef("company_id", Company)]
36+
"""The company this fiscal position is associated with.
37+
38+
This fetches the full record from Odoo once,
39+
and caches it for subsequent accesses.
40+
"""
41+
42+
name: str
43+
"""The name of the fiscal position.
44+
45+
Not guaranteed to be unique.
46+
"""
47+
48+
tax_ids: Annotated[list[int], ModelRef("tax_ids", Tax)]
49+
"""The list of IDs for the taxes that will be applied
50+
to sale orders and invoices for partners using this
51+
fiscal position.
52+
"""
53+
54+
taxes: Annotated[list[Tax], ModelRef("tax_ids", Tax)]
55+
"""The list of taxes that will be applied
56+
to sale orders and invoices for partners using this
57+
fiscal position.
58+
59+
This fetches the full records from Odoo once,
60+
and caches them for subsequent accesses.
61+
"""
62+
63+
64+
class FiscalPositionManager(RecordManagerBase[FiscalPosition]):
65+
env_name = "account.fiscal.position"
66+
record_class = FiscalPosition
67+
68+
69+
# NOTE(callumdickinson): Import here to make sure circular imports work.
70+
from .company import Company # noqa: E402
71+
from .tax import Tax # noqa: E402

openstack_odooclient/managers/partner.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,36 @@ class Partner(RecordBase["PartnerManager"]):
4444
email: str
4545
"""Main e-mail address for the partner."""
4646

47+
fiscal_position_id: Annotated[
48+
int | None,
49+
ModelRef("fiscal_position_id", FiscalPosition),
50+
]
51+
"""The ID for the fiscal position this partner uses, if it uses one.
52+
53+
*Added in version 0.2.4.*
54+
"""
55+
56+
fiscal_position_name: Annotated[
57+
str | None,
58+
ModelRef("fiscal_position_id", FiscalPosition),
59+
]
60+
"""The name of the fiscal position this partner uses, if it uses one.
61+
62+
*Added in version 0.2.4.*
63+
"""
64+
65+
fiscal_position: Annotated[
66+
FiscalPosition | None,
67+
ModelRef("fiscal_position_id", FiscalPosition),
68+
]
69+
"""The fiscal position this partner uses, if it uses one.
70+
71+
This fetches the full record from Odoo once,
72+
and caches it for subsequent accesses.
73+
74+
*Added in version 0.2.4.*
75+
"""
76+
4777
name: str
4878
"""Full name of the partner."""
4979

@@ -281,6 +311,7 @@ class PartnerManager(RecordManagerBase[Partner]):
281311
# NOTE(callumdickinson): Import here to make sure circular imports work.
282312
from .company import Company # noqa: E402
283313
from .customer_group import CustomerGroup # noqa: E402
314+
from .fiscal_position import FiscalPosition # noqa: E402
284315
from .pricelist import Pricelist # noqa: E402
285316
from .project import Project # noqa: E402
286317
from .project_contact import ProjectContact # noqa: E402

0 commit comments

Comments
 (0)