Skip to content

Commit

Permalink
Merge PR #1543 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by bguillot
  • Loading branch information
OCA-git-bot committed Jul 5, 2023
2 parents dc19d6a + b4f7d61 commit 4e3207b
Show file tree
Hide file tree
Showing 13 changed files with 651 additions and 0 deletions.
85 changes: 85 additions & 0 deletions partner_address_split/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
==============
Partner Helper
==============

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/14.0/partner_helper
: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-14-0/partner-contact-14-0-partner_helper
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/134/14.0
:alt: Try me on Runbot

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

The purpose of this module is to gather generic partner methods.
It avoids to grow up excessively the number of modules in Odoo
for small features.

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_helper%0Aversion:%2014.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]>

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/14.0/partner_helper>`_ 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": "16.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",
}
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(result[index] + " %s" % word) > size:
break
else:
result[index] += " %s" % 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("{} {}".format(street, street2), output_number, max_size)
3 changes: 3 additions & 0 deletions partner_address_split/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Akretion:

* Sébastien Beau <[email protected]>
9 changes: 9 additions & 0 deletions partner_address_split/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The purpose of this module is to gather generic method to spliit 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

0 comments on commit 4e3207b

Please sign in to comment.