-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0] Add shopinvader_schema_invoice + shopinvader_api_invoice + shopinvader_api_security_invoice #1493
base: 16.0
Are you sure you want to change the base?
Conversation
ref: str | str | ||
payment_reference: str | str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
ref: str | str | |
payment_reference: str | str | |
ref: str | None | |
payment_reference: str | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is normally I string I'd rather stick to an empty string as default.
Do you see any implications?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be a matter of test. str | None
perhaps communicates more explicitly that the value can be set or not set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
str | None
means the value can be a string or None. I don't understant what str | str
means. If you want an empty string by default it should be declared as 'ref : str = ""'
Thanks for doing this, @simahawk ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (nothing more than Stephane's comments). Thanks for having done it!
It introduces the following schema: | ||
|
||
* Invoice | ||
* InvoiceAmount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be updated
# Moreover, having a rule for records not tied to partners | ||
# can be quite complicated. | ||
# Let's use sudo! | ||
count = env["account.move"].sudo().search_count(domain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could have a RR that give access to invoice to the authenticated partner. In this way you can search without sudo and then call Invoice.from_records(invoices.sudo())
We are therefore sure that the security is properly applied.
ref: str | str | ||
payment_reference: str | str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
str | None
means the value can be a string or None. I don't understant what str | str
means. If you want an empty string by default it should be declared as 'ref : str = ""'
amount: InvoiceAmount | None | ||
|
||
@classmethod | ||
def from_record(cls, odoo_rec): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to name from which odoo model we construct the fastapi model.
def from_record(cls, odoo_rec): | |
def from_account_move(cls, odoo_rec): |
) | ||
|
||
@classmethod | ||
def from_records(cls, odoo_recs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see previous comment
amount_due: float | None | ||
|
||
@classmethod | ||
def from_record(cls, odoo_rec): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feom which odoo model?
def from_record(cls, odoo_rec): | |
def from_account_move(cls, odoo_rec): |
from odoo.tools.float_utils import float_round | ||
|
||
|
||
class InvoiceAmount(StrictExtendableBaseModel, extra="ignore"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to declare extra="ignore"
? A common use of this parameter is for models used as incoming message. In this case we want to ignore unknown attributes.
invoicing_legacy = "invoicing_legacy" | ||
|
||
|
||
class Invoice(StrictExtendableBaseModel, extra="ignore"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? extra="ignore"
?
Superseded by #1572 |
Replaces #1365