Skip to content
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

[18.0][MIG] partner_address_split: Migration to 18.0 #1944

Open
wants to merge 7 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions partner_address_split/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
=====================
Partner Address Split
=====================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:25ea80f6e1d7d570c36033533d70cc214d9c778464e34f244cad821fe272aef4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github
:target: https://github.com/OCA/partner-contact/tree/18.0/partner_address_split
:alt: OCA/partner-contact
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-0-partner_address_split
: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/partner-contact&target_branch=18.0
:alt: Try me on Runboat

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

The purpose of this module is to gather generic method to split address.

Add methods to Partner model like \_get_split_address()

This method allows to get a number of street fields according to your
choice. 2 fields by default in Odoo with 128 width chars. In some
countries you have constraints on width of street fields and you
should use 3 or 4 shorter fields. You also need of this feature to
avoid headache with overflow printing task

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/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/partner-contact/issues/new?body=module:%20partner_address_split%0Aversion:%2018.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.

Credits
=======

Authors
-------

* Akretion

Contributors
------------

- Akretion:

- Sébastien Beau <[email protected]>

- ``Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>``\ \_

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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/partner-contact <https://github.com/OCA/partner-contact/tree/18.0/partner_address_split>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions partner_address_split/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions partner_address_split/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Author: Sébastien BEAU <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Partner Address Split",
"version": "18.0.1.0.0",
"author": "Akretion,Odoo Community Association (OCA)",
"maintainer": "Akretion",
"category": "Warehouse",
"depends": [
"base",
],
"summary": "Add specific helper methods",
"website": "https://github.com/OCA/partner-contact",
"installable": True,
"auto_install": False,
"license": "AGPL-3",
}
22 changes: 22 additions & 0 deletions partner_address_split/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_address_split
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-06-24 13:35+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: partner_address_split
#: model:ir.model,name:partner_address_split.model_res_partner
msgid "Contact"
msgstr "Contatto"
19 changes: 19 additions & 0 deletions partner_address_split/i18n/partner_address_split.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_address_split
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \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: partner_address_split
#: model:ir.model,name:partner_address_split.model_res_partner
msgid "Contact"
msgstr ""
1 change: 1 addition & 0 deletions partner_address_split/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import partner
48 changes: 48 additions & 0 deletions partner_address_split/models/partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright (C) 2016 Akretion (http://www.akretion.com)
# Author: Sébastien BEAU <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


def split_char(char, output_number, size):
words = char.split(" ")
result = []
word = words.pop(0)
for index in range(0, output_number):
result.append(word)
word = ""
while len(words) > 0:
word = words.pop(0)
if len(f"{result[index]} {word}") > size:
break
else:
result[index] += f" {word}"
word = ""
return result


class ResPartner(models.Model):
_inherit = "res.partner"

def _get_split_address(self, output_number, max_size):
"""This method allows to get a number of street fields according to
your choice. Default is 2 large fields in Odoo (128 chars).
In some countries you may use 3 or 4 shorter street fields.

example:
res = self.partner_id._get_split_address(3, 35)
street1, street2, street3 = res
"""
self.ensure_one()
street = self.street or ""
street2 = self.street2 or ""
if len(street) <= max_size and len(street2) <= max_size:
result = ["" for i in range(0, output_number)]
result[0] = street
result[1] = street2
return result
elif len(street) <= max_size:
return [street] + split_char(street2, output_number - 1, max_size)
else:
return split_char(f"{street} {street2}", output_number, max_size)
3 changes: 3 additions & 0 deletions partner_address_split/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions partner_address_split/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Akretion:

> - Sébastien Beau \<<[email protected]>\>
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`_
10 changes: 10 additions & 0 deletions partner_address_split/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
The purpose of this module is to gather generic method to split
address.

Add methods to Partner model like \_get_split_address()

> This method allows to get a number of street fields according to your
> choice. 2 fields by default in Odoo with 128 width chars. In some
> countries you have constraints on width of street fields and you
> should use 3 or 4 shorter fields. You also need of this feature to
> avoid headache with overflow printing task
Binary file added partner_address_split/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading