Skip to content

Commit 8d88c19

Browse files
Callum027Callum Dickinson
andauthored
Add tax fields to record types (#22)
* Add the ``taxes_id`` (with ``tax_ids`` alias) and ``taxes`` fields to the ``Product`` record type. * Add the ``tax_ids`` and ``taxes`` fields to the ``AccountMoveLine`` record type. Co-authored-by: Callum Dickinson <callum.dickinson@catalystcloud.nz>
1 parent f7ada7b commit 8d88c19

File tree

5 files changed

+100
-1
lines changed

5 files changed

+100
-1
lines changed

changelog.d/22.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add tax fields to record types

docs/managers/account-move-line.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,27 @@ quantity: float
241241
```
242242

243243
Quantity of product charged on the account move (invoice) line.
244+
245+
### `tax_ids`
246+
247+
```python
248+
tax_ids: list[int]
249+
```
250+
251+
The list of IDs for the taxes that are applied
252+
on this account move (invoice) line.
253+
254+
*Added in version 0.2.3.*
255+
256+
### `taxes`
257+
258+
```python
259+
taxes: list[Tax]
260+
```
261+
262+
The list of taxes that are applied on this account move (invoice) line.
263+
264+
This fetches the full records from Odoo once,
265+
and caches them for subsequent accesses.
266+
267+
*Added in version 0.2.3.*

docs/managers/product.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,40 @@ Whether or not this product is sellable.
375375

376376
*Added in version 0.2.1.*
377377

378+
### `tax_ids`
379+
380+
```python
381+
tax_ids: list[int]
382+
```
383+
384+
An alias for [``taxes_id``](#taxes_id).
385+
386+
*Added in version 0.2.3.*
387+
388+
### `taxes_id`
389+
390+
```python
391+
taxes_id: list[int]
392+
```
393+
394+
The list of IDs for the default taxes that are used
395+
when selling this product.
396+
397+
*Added in version 0.2.3.*
398+
399+
### `taxes`
400+
401+
```python
402+
taxes: list[Tax]
403+
```
404+
405+
The list of default taxes used when selling this product.
406+
407+
This fetches the full records from Odoo once,
408+
and caches them for subsequent accesses.
409+
410+
*Added in version 0.2.3.*
411+
378412
### `uom_id`
379413

380414
```python

openstack_odooclient/managers/account_move_line.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,22 @@ class AccountMoveLine(RecordBase["AccountMoveLineManager"]):
130130
quantity: float
131131
"""Quantity of product charged on the account move (invoice) line."""
132132

133+
tax_ids: Annotated[list[int], ModelRef("tax_ids", Tax)]
134+
"""The list of IDs for the taxes that are applied
135+
on this account move (invoice) line.
136+
137+
*Added in version 0.2.3.*
138+
"""
139+
140+
taxes: Annotated[list[Tax], ModelRef("tax_ids", Tax)]
141+
"""The list of taxes that are applied on this account move (invoice) line.
142+
143+
This fetches the full records from Odoo once,
144+
and caches them for subsequent accesses.
145+
146+
*Added in version 0.2.3.*
147+
"""
148+
133149

134150
class AccountMoveLineManager(RecordManagerBase[AccountMoveLine]):
135151
env_name = "account.move.line"
@@ -141,3 +157,4 @@ class AccountMoveLineManager(RecordManagerBase[AccountMoveLine]):
141157
from .currency import Currency # noqa: E402
142158
from .product import Product # noqa: E402
143159
from .project import Project # noqa: E402
160+
from .tax import Tax # noqa: E402

openstack_odooclient/managers/product.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from typing import TYPE_CHECKING, Annotated, Any, Literal, overload
1919

2020
from ..base.record.base import RecordBase
21-
from ..base.record.types import ModelRef
21+
from ..base.record.types import FieldAlias, ModelRef
2222
from ..base.record_manager.base import RecordManagerBase
2323

2424
if TYPE_CHECKING:
@@ -88,6 +88,28 @@ class Product(RecordBase["ProductManager"]):
8888
*Added in version 0.2.1.*
8989
"""
9090

91+
tax_ids: Annotated[list[int], FieldAlias("taxes_id")]
92+
"""An alias for ``taxes_id``.
93+
94+
*Added in version 0.2.3.*
95+
"""
96+
97+
taxes_id: Annotated[list[int], ModelRef("taxes_id", Tax)]
98+
"""The list of IDs for the default taxes that are used
99+
when selling this product.
100+
101+
*Added in version 0.2.3.*
102+
"""
103+
104+
taxes: Annotated[list[Tax], ModelRef("taxes_id", Tax)]
105+
"""The list of default taxes used when selling this product.
106+
107+
This fetches the full records from Odoo once,
108+
and caches them for subsequent accesses.
109+
110+
*Added in version 0.2.3.*
111+
"""
112+
91113
uom_id: Annotated[int, ModelRef("uom_id", Uom)]
92114
"""The ID for the Unit of Measure for this product."""
93115

@@ -366,4 +388,5 @@ def get_sellable_company_product_by_name(
366388
# NOTE(callumdickinson): Import here to make sure circular imports work.
367389
from .company import Company # noqa: E402
368390
from .product_category import ProductCategory # noqa: E402
391+
from .tax import Tax # noqa: E402
369392
from .uom import Uom # noqa: E402

0 commit comments

Comments
 (0)