-
Notifications
You must be signed in to change notification settings - Fork 105
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
[ADD][16.0] address shipping note #1374 #1553
base: 16.0
Are you sure you want to change the base?
[ADD][16.0] address shipping note #1374 #1553
Conversation
@@ -49,7 +49,7 @@ def setUpClass(cls) -> None: | |||
cls.default_fastapi_authenticated_partner = cls.test_partner | |||
cls.default_fastapi_router = address_router | |||
|
|||
def test_get_invoicing_address(self): | |||
def test_get_billing_address(self): |
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 renaming this test from invoicing to billing? Because it does a get of /addresses/invoicing.
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 reverted it
3d901bd
to
3a59539
Compare
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 (code review)
return res | ||
|
||
|
||
class ShippingAddressNoteCreate(DeliveryAddressCreate, extends=DeliveryAddressCreate): |
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.
class ShippingAddressNoteCreate(DeliveryAddressCreate, extends=DeliveryAddressCreate): | |
class ShippingAddressNoteCreate(DeliveryAddressCreate, extends=True): |
return vals | ||
|
||
|
||
class ShippingAddressNoteUpdate(DeliveryAddressUpdate, extends=DeliveryAddressUpdate): |
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.
class ShippingAddressNoteUpdate(DeliveryAddressUpdate, extends=DeliveryAddressUpdate): | |
class ShippingAddressNoteUpdate(DeliveryAddressUpdate, extends=True): |
with self._create_test_client(router=address_router) as test_client: | ||
response: Response = test_client.get( | ||
"/addresses/delivery", | ||
) |
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 avoid to always have to pass the router on each call to _create_test_client
you should assign the address_router
to the property default_fastapi_router
into your setUpClass
|
||
def to_res_partner_vals(self) -> dict: | ||
vals = super().to_res_partner_vals() | ||
shipping_note = self.shipping_note |
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.
With partial update, it's not required to set the field into the json you pass to odoo when updating the address. With your code, you' don't make the difference between to cases:
- The field is not set into the json -> value is None in python and we don't want to update it
- The field is set to null into the json -> value is None in python and we want to update it...
To covers both cases you must call the model_dump
to retrieve fields really given to instanciate the model:
values = self.model_dump(exclude_unset=True, include=["shipping_note"])
if "shipping_note" in values:
vals["shipping_note"] = values["shipping_note"
return vals]
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.
Thanks, I updated the code
239b573
to
c64193a
Compare
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 (code + functional review), requested changes have been fixed, requested a very minor not blocking change.
def _call_test_client(self, url, http_code=status.HTTP_200_OK, **kwargs): | ||
method = kwargs.pop("method", "get") | ||
with self._create_test_client( | ||
router=self.default_fastapi_router |
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.
This is not necessary as cls.default_fastapi_router
is already setting the default router: https://github.com/OCA/rest-framework/blob/16.0/fastapi/tests/common.py#L146
router=self.default_fastapi_router |
Simply a cherry-pick of relevant commits of #1374
cc @AnizR @sebastienbeau