diff --git a/shopinvader_api_address/schemas.py b/shopinvader_api_address/schemas.py index ba7d13cbfd..4662b466a0 100644 --- a/shopinvader_api_address/schemas.py +++ b/shopinvader_api_address/schemas.py @@ -20,6 +20,7 @@ class AddressCreate(StrictExtendableBaseModel, extra="ignore"): email: str | None = None state_id: int | None = None country_id: int | None = None + title_id: int | None = None def to_res_partner_vals(self) -> dict: vals = { @@ -33,6 +34,7 @@ def to_res_partner_vals(self) -> dict: "email": self.email, "state_id": self.state_id, "country_id": self.country_id, + "title": self.title_id, } return vals @@ -54,6 +56,7 @@ class AddressUpdate(StrictExtendableBaseModel, extra="ignore"): email: str | None = None state_id: int | None = None country_id: int | None = None + title_id: int | None = None def to_res_partner_vals(self) -> dict: fields = [ @@ -69,7 +72,10 @@ def to_res_partner_vals(self) -> dict: "country_id", ] values = self.model_dump(exclude_unset=True) - return {f: values[f] for f in fields if f in values} + result = {f: values[f] for f in fields if f in values} + if "title_id" in values: + result["title"] = values["title_id"] + return result # --- Invoicing Address --- diff --git a/shopinvader_api_address/tests/test_shopinvader_address_api.py b/shopinvader_api_address/tests/test_shopinvader_address_api.py index 4f76c4dea0..b5c57c27d8 100644 --- a/shopinvader_api_address/tests/test_shopinvader_address_api.py +++ b/shopinvader_api_address/tests/test_shopinvader_address_api.py @@ -43,6 +43,7 @@ def setUpClass(cls) -> None: "zip": "1410", "city": "Waterloo", "country_id": cls.env.ref("base.be").id, + "title": cls.env.ref("base.res_partner_title_madam").id, } ) @@ -75,6 +76,7 @@ def test_get_invoicing_address(self): self.assertEqual(address.get("city"), self.test_partner.city) self.assertEqual(address.get("country_id"), self.test_partner.country_id.id) self.assertEqual(address.get("id"), self.test_partner.id) + self.assertEqual(address.get("title_id"), self.test_partner.title.id) with self._create_test_client(router=address_router) as test_client: response: Response = test_client.get( @@ -98,6 +100,7 @@ def test_get_invoicing_address(self): self.assertEqual(address.get("city"), self.test_partner.city) self.assertEqual(address.get("country_id"), self.test_partner.country_id.id) self.assertEqual(address.get("id"), self.test_partner.id) + self.assertEqual(address.get("title_id"), self.test_partner.title.id) def test_get_delivery_address(self): """ @@ -186,6 +189,7 @@ def test_update_invoicing_address(self): "city": "Waterloo", "country_id": self.env.ref("base.be").id, "street": "test Street", + "title_id": self.env.ref("base.res_partner_title_madam").id, } with self._create_test_client(router=address_router) as test_client: diff --git a/shopinvader_schema_address/schemas.py b/shopinvader_schema_address/schemas.py index f05f0e8aa5..97a64b2e5b 100644 --- a/shopinvader_schema_address/schemas.py +++ b/shopinvader_schema_address/schemas.py @@ -16,6 +16,7 @@ class Address(StrictExtendableBaseModel): email: str | None = None state_id: int | None = None country_id: int | None = None + title_id: int | None = None @classmethod def from_res_partner(cls, odoo_rec): @@ -31,6 +32,7 @@ def from_res_partner(cls, odoo_rec): email=odoo_rec.email or None, state_id=odoo_rec.state_id.id or None, country_id=odoo_rec.country_id.id or None, + title_id=odoo_rec.title.id or None, )