Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
yostashiro committed Feb 3, 2024
1 parent d0d9948 commit a88200a
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 120 deletions.
2 changes: 0 additions & 2 deletions l10n_jp_partner_postcode_address/models/__init__.py

This file was deleted.

81 changes: 0 additions & 81 deletions l10n_jp_partner_postcode_address/models/zip_code_search_mixin.py

This file was deleted.

1 change: 0 additions & 1 deletion l10n_jp_partner_postcode_address/readme/DESCRIPTION.rst

This file was deleted.

13 changes: 0 additions & 13 deletions l10n_jp_partner_postcode_address/views/res_partner_views.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
==============================
Japan Partner Postcode Address
==============================
=========================
Japan Partner Zip Address
=========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9cf00c1ae529de14f57d45329b7c37e0e0dfd9325c4f9c633ca39919cedf32e2
!! source digest: sha256:a0b6b578feeacc9023a83721e0f203a100cb11b182904f79f9931861f48ca897
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -17,18 +17,23 @@ Japan Partner Postcode Address
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--japan-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-japan/tree/15.0/l10n_jp_partner_postcode_address
:target: https://github.com/OCA/l10n-japan/tree/15.0/l10n_jp_partner_zip_address
:alt: OCA/l10n-japan
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-japan-15-0/l10n-japan-15-0-l10n_jp_partner_postcode_address
:target: https://translation.odoo-community.org/projects/l10n-japan-15-0/l10n-japan-15-0-l10n_jp_partner_zip_address
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-japan&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows users to input a zip code and automatically fills in the corresponding address details of the partner.
This module introduces a function that automatically retrieves and fills in the Japanese
address details for a partner using the zipcloud service, provided that the following
conditions are met.

* Country is Japan or no country is set for the partner.
* A valid postcode is entered for the partner.

**Table of contents**

Expand All @@ -41,7 +46,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-japan/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-japan/issues/new?body=module:%20l10n_jp_partner_postcode_address%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/l10n-japan/issues/new?body=module:%20l10n_jp_partner_zip_address%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -66,6 +71,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/l10n-japan <https://github.com/OCA/l10n-japan/tree/15.0/l10n_jp_partner_postcode_address>`_ project on GitHub.
This module is part of the `OCA/l10n-japan <https://github.com/OCA/l10n-japan/tree/15.0/l10n_jp_partner_zip_address>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# Copyright 2024 Quartile Limited
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Japan Partner Postcode Address",
"name": "Japan Partner Zip Address",
"version": "15.0.1.0.0",
"author": "Quartile Limited, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/l10n-japan",
"category": "Localization",
"depends": ["base"],
"external_dependencies": {"python": ["jaconv"]},
"data": [
"views/res_partner_views.xml",
],
"installable": True,
}
38 changes: 38 additions & 0 deletions l10n_jp_partner_zip_address/l18n/ja.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_jp_partner_zip_address
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-03 10:03+0000\n"
"PO-Revision-Date: 2024-02-03 10:03+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: l10n_jp_partner_zip_address
#: model:ir.model,name:l10n_jp_partner_zip_address.model_res_partner
msgid "Contact"
msgstr "連絡先"

#. module: l10n_jp_partner_zip_address
#: code:addons/l10n_jp_partner_zip_address/models/zip_search_mixin.py:0
#, python-format
msgid "Only digits are allowed."
msgstr "数値のみで入力してください。"

#. module: l10n_jp_partner_zip_address
#: code:addons/l10n_jp_partner_zip_address/models/zip_search_mixin.py:0
#, python-format
msgid "Postcode should be 7 digits."
msgstr "郵便番号には7桁の数値を入れてください。"

#. module: l10n_jp_partner_zip_address
#: model:ir.model,name:l10n_jp_partner_zip_address.model_zip_search_mixin
msgid "zip.search.mixin"
msgstr ""
2 changes: 2 additions & 0 deletions l10n_jp_partner_zip_address/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import zip_search_mixin
from . import res_partner
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

class ResPartner(models.Model):
_name = "res.partner"
_inherit = ["res.partner", "zip.code.search.mixin"]
_inherit = ["res.partner", "zip.search.mixin"]
59 changes: 59 additions & 0 deletions l10n_jp_partner_zip_address/models/zip_search_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2024 Quartile Limited
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import logging

import requests

from odoo import _, api, models
from odoo.exceptions import UserError

try:
import jaconv
except (ImportError, IOError) as err:
logging.getLogger(__name__).warning(err)

Check warning on line 14 in l10n_jp_partner_zip_address/models/zip_search_mixin.py

View check run for this annotation

Codecov / codecov/patch

l10n_jp_partner_zip_address/models/zip_search_mixin.py#L13-L14

Added lines #L13 - L14 were not covered by tests


class ZipSearchMixin(models.AbstractModel):
_name = "zip.search.mixin"

def sanitize_zip(self, zipcode):
field = jaconv.z2h(zipcode, ascii=True, digit=True).replace("-", "")

Check warning on line 21 in l10n_jp_partner_zip_address/models/zip_search_mixin.py

View check run for this annotation

Codecov / codecov/patch

l10n_jp_partner_zip_address/models/zip_search_mixin.py#L21

Added line #L21 was not covered by tests
if not field.isdigit():
raise UserError(_("Only digits are allowed."))

Check warning on line 23 in l10n_jp_partner_zip_address/models/zip_search_mixin.py

View check run for this annotation

Codecov / codecov/patch

l10n_jp_partner_zip_address/models/zip_search_mixin.py#L23

Added line #L23 was not covered by tests
elif len(field) != 7:
field = False
raise UserError(_("Postcode should be 7 digits."))
return field

Check warning on line 27 in l10n_jp_partner_zip_address/models/zip_search_mixin.py

View check run for this annotation

Codecov / codecov/patch

l10n_jp_partner_zip_address/models/zip_search_mixin.py#L25-L27

Added lines #L25 - L27 were not covered by tests

def _make_zip_request(self, request_url):
try:
response = requests.get(request_url)
response.raise_for_status() # Raise HTTPError for bad responses
return response.json()

Check warning on line 33 in l10n_jp_partner_zip_address/models/zip_search_mixin.py

View check run for this annotation

Codecov / codecov/patch

l10n_jp_partner_zip_address/models/zip_search_mixin.py#L30-L33

Added lines #L30 - L33 were not covered by tests
except requests.exceptions.HTTPError as http_err:
return {"status": response.status_code, "message": str(http_err)}
except requests.exceptions.RequestException as req_err:
return {"status": 500, "message": f"Request error: {str(req_err)}"}

Check warning on line 37 in l10n_jp_partner_zip_address/models/zip_search_mixin.py

View check run for this annotation

Codecov / codecov/patch

l10n_jp_partner_zip_address/models/zip_search_mixin.py#L35-L37

Added lines #L35 - L37 were not covered by tests

@api.onchange("zip")
def _onchange_zip(self):
japan = self.env.ref("base.jp")

Check warning on line 41 in l10n_jp_partner_zip_address/models/zip_search_mixin.py

View check run for this annotation

Codecov / codecov/patch

l10n_jp_partner_zip_address/models/zip_search_mixin.py#L41

Added line #L41 was not covered by tests
if (self.country_id and self.country_id != japan) or not self.zip:
return
self.zip = self.sanitize_zip(self.zip)
request_url = f"http://zipcloud.ibsnet.co.jp/api/search?zipcode={self.zip}"
response_data = self._make_zip_request(request_url)

Check warning on line 46 in l10n_jp_partner_zip_address/models/zip_search_mixin.py

View check run for this annotation

Codecov / codecov/patch

l10n_jp_partner_zip_address/models/zip_search_mixin.py#L43-L46

Added lines #L43 - L46 were not covered by tests
if response_data["status"] != 200:
raise UserError(response_data["message"])
self.state_id = False
self.city = False
self.street = False
address_data = response_data["results"]

Check warning on line 52 in l10n_jp_partner_zip_address/models/zip_search_mixin.py

View check run for this annotation

Codecov / codecov/patch

l10n_jp_partner_zip_address/models/zip_search_mixin.py#L48-L52

Added lines #L48 - L52 were not covered by tests
if address_data:
self.state_id = self.env["res.country.state"].search(

Check warning on line 54 in l10n_jp_partner_zip_address/models/zip_search_mixin.py

View check run for this annotation

Codecov / codecov/patch

l10n_jp_partner_zip_address/models/zip_search_mixin.py#L54

Added line #L54 was not covered by tests
[("name", "=", address_data[0]["address1"])], limit=1
)
self.city = address_data[0]["address2"]
self.street = address_data[0]["address3"]
self.country_id = japan

Check warning on line 59 in l10n_jp_partner_zip_address/models/zip_search_mixin.py

View check run for this annotation

Codecov / codecov/patch

l10n_jp_partner_zip_address/models/zip_search_mixin.py#L57-L59

Added lines #L57 - L59 were not covered by tests
6 changes: 6 additions & 0 deletions l10n_jp_partner_zip_address/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module introduces a function that automatically retrieves and fills in the Japanese
address details for a partner using the zipcloud service, provided that the following
conditions are met.

* Country is Japan or no country is set for the partner.
* A valid postcode is entered for the partner.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Japan Partner Postcode Address</title>
<title>Japan Partner Zip Address</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,17 +360,23 @@
</style>
</head>
<body>
<div class="document" id="japan-partner-postcode-address">
<h1 class="title">Japan Partner Postcode Address</h1>
<div class="document" id="japan-partner-zip-address">
<h1 class="title">Japan Partner Zip Address</h1>

<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9cf00c1ae529de14f57d45329b7c37e0e0dfd9325c4f9c633ca39919cedf32e2
!! source digest: sha256:a0b6b578feeacc9023a83721e0f203a100cb11b182904f79f9931861f48ca897
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-japan/tree/15.0/l10n_jp_partner_postcode_address"><img alt="OCA/l10n-japan" src="https://img.shields.io/badge/github-OCA%2Fl10n--japan-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-japan-15-0/l10n-japan-15-0-l10n_jp_partner_postcode_address"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-japan&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows users to input a zip code and automatically fills in the corresponding address details of the partner.</p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-japan/tree/15.0/l10n_jp_partner_zip_address"><img alt="OCA/l10n-japan" src="https://img.shields.io/badge/github-OCA%2Fl10n--japan-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-japan-15-0/l10n-japan-15-0-l10n_jp_partner_zip_address"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-japan&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module introduces a function that automatically retrieves and fills in the Japanese
address details for a partner using the zipcloud service, provided that the following
conditions are met.</p>
<ul class="simple">
<li>Country is Japan or no country is set for the partner.</li>
<li>A valid postcode is entered for the partner.</li>
</ul>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand All @@ -387,7 +393,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/l10n-japan/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/l10n-japan/issues/new?body=module:%20l10n_jp_partner_postcode_address%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/l10n-japan/issues/new?body=module:%20l10n_jp_partner_zip_address%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -405,7 +411,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/l10n-japan/tree/15.0/l10n_jp_partner_postcode_address">OCA/l10n-japan</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/l10n-japan/tree/15.0/l10n_jp_partner_zip_address">OCA/l10n-japan</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down

This file was deleted.

File renamed without changes.

0 comments on commit a88200a

Please sign in to comment.