forked from shopinvader/odoo-shopinvader
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c6f5fe
commit 9d5058d
Showing
14 changed files
with
197 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,18 @@ | |
# @author Pierrick Brun <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from typing import List | ||
from typing import List, Optional | ||
from datetime import datetime | ||
|
||
from extendable_pydantic import ExtendableModelMeta | ||
from pydantic import BaseModel, EmailStr, Field | ||
from pydantic import BaseModel, EmailStr, Field, ConfigDict | ||
|
||
from .attachment import AttachableInfo | ||
from .base import IdAndNameInfo, IdRequest | ||
from .mail_message import MailThreadInfo | ||
from odoo.addons.pydantic import utils | ||
from odoo import fields | ||
|
||
from ..pydantic_models.mail_message import MailThreadInfo | ||
|
||
|
||
class HelpdeskPartnerRequest(BaseModel): | ||
|
@@ -22,6 +23,8 @@ class HelpdeskPartnerRequest(BaseModel): | |
|
||
|
||
class HelpdeskTicketSaleLineRequest(BaseModel): | ||
model_config = ConfigDict(from_attributes=True) | ||
|
||
sale_line_id: int | ||
qty: int = None | ||
|
||
|
@@ -31,8 +34,16 @@ class HelpdeskTicketSaleLineInfo(BaseModel): | |
qty: int | ||
product_name: str = None | ||
|
||
@classmethod | ||
def from_rec(cls, sol): | ||
return cls.model_construct( | ||
sale_line_id=sol.id, qty=sol.qty, product_name=sol.product_name | ||
) | ||
|
||
|
||
class HelpdeskTicketInfo(AttachableInfo, MailThreadInfo): | ||
model_config = ConfigDict(from_attributes=True) | ||
|
||
id: int | ||
name: str | ||
description: str | ||
|
@@ -45,8 +56,34 @@ class HelpdeskTicketInfo(AttachableInfo, MailThreadInfo): | |
sale: IdAndNameInfo = Field(None, alias="sale_id") | ||
sale_lines: List[HelpdeskTicketSaleLineInfo] = Field([], alias="sale_line_ids") | ||
|
||
@classmethod | ||
def from_rec(cls, odoo_rec): | ||
return cls.model_construct( | ||
id=odoo_rec.id, | ||
name=odoo_rec.name or None, | ||
description=odoo_rec.description or None, | ||
create_date=fields.Datetime.context_timestamp( | ||
odoo_rec, odoo_rec.create_date | ||
) | ||
if odoo_rec.create_date | ||
else None, | ||
last_stage_update=fields.Datetime.context_timestamp( | ||
odoo_rec, odoo_rec.last_stage_update | ||
) | ||
if odoo_rec.last_stage_update | ||
else None, | ||
category=IdAndNameInfo.from_rec(odoo_rec.category_id), | ||
team=IdAndNameInfo.from_rec(odoo_rec.team_id), | ||
stage=IdAndNameInfo.from_rec(odoo_rec.stage_id), | ||
sale=IdAndNameInfo.from_rec(odoo_rec.sale_id), | ||
sale_lines=[ | ||
HelpdeskTicketSaleLineInfo.from_rec(sol) | ||
for sol in odoo_rec.sale_line_ids | ||
], | ||
) | ||
|
||
|
||
class HelpdeskTicketRequest(BaseModel, metaclass=ExtendableModelMeta): | ||
class HelpdeskTicketRequest(BaseModel): | ||
name: str | ||
description: str | ||
partner: HelpdeskPartnerRequest = Field(None) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
from . import attachment_mixin | ||
from . import service | ||
from . import abstract_mail_thread | ||
from . import ticket | ||
from . import settings |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.