Skip to content

Commit

Permalink
Merge pull request #1153 from OCA/14.0
Browse files Browse the repository at this point in the history
Syncing from upstream OCA/partner-contact (14.0)
  • Loading branch information
bt-admin authored Feb 17, 2024
2 parents e5df002 + 9d163e7 commit 7e5e935
Show file tree
Hide file tree
Showing 21 changed files with 813 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ addon | version | maintainers | summary
[partner_priority](partner_priority/) | 14.0.1.0.0 | [![patrickrwilson](https://github.com/patrickrwilson.png?size=30px)](https://github.com/patrickrwilson) | Adds priority to partners.
[partner_ref_unique](partner_ref_unique/) | 14.0.1.0.0 | | Add an unique constraint to partner ref field
[partner_second_lastname](partner_second_lastname/) | 14.0.1.1.0 | | Have split first and second lastnames
[partner_sequence_address_type](partner_sequence_address_type/) | 14.0.1.0.0 | [![aleuffre](https://github.com/aleuffre.png?size=30px)](https://github.com/aleuffre) [![renda-dev](https://github.com/renda-dev.png?size=30px)](https://github.com/renda-dev) [![PicchiSeba](https://github.com/PicchiSeba.png?size=30px)](https://github.com/PicchiSeba) | Partner Sequence Address Type
[partner_stage](partner_stage/) | 14.0.2.1.1 | [![dreispt](https://github.com/dreispt.png?size=30px)](https://github.com/dreispt) | Add lifecycle Stages to Partners
[partner_tier_validation](partner_tier_validation/) | 14.0.3.0.2 | [![dreispt](https://github.com/dreispt.png?size=30px)](https://github.com/dreispt) | Support a tier validation process for Contacts
[partner_title_order](partner_title_order/) | 14.0.1.0.0 | | Makes partner title sortable by sequence
Expand Down
108 changes: 108 additions & 0 deletions partner_sequence_address_type/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
=============================
Partner Sequence Address Type
=============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:10536ec3b39ef36f49a5b973d37792b1e2842dc9f2f349f3c3658244f66b199f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_sequence_address_type
: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_sequence_address_type
: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=14.0
:alt: Try me on Runboat

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

This module allows to use different sequences to generate values for Reference field in partner, according to their address type.


It also makes Reference field visible when opening records from "Contacts & Addresses" kanban cards.


Please note: in this module child contacts do not inherit Reference value from parent contact, and value of field Reference is never read-only.

**Table of contents**

.. contents::
:local:

Usage
=====

Users with access rights Administration: access rights can access menu "Partner Sequence by Address Type" from Contacts > Configuration and set a sequence for each address type.

Address types without sequence will not have a Reference value assigned automatically.

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_sequence_address_type%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
~~~~~~~

* PyTech SRL
* Ooops404

Contributors
~~~~~~~~~~~~

* `PyTech SRL <https://www.pytech.it>`__:

* Alessio Renda

* `Ooops404 <https://www.ooops404.com>`__

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.

.. |maintainer-aleuffre| image:: https://github.com/aleuffre.png?size=40px
:target: https://github.com/aleuffre
:alt: aleuffre
.. |maintainer-renda-dev| image:: https://github.com/renda-dev.png?size=40px
:target: https://github.com/renda-dev
:alt: renda-dev
.. |maintainer-PicchiSeba| image:: https://github.com/PicchiSeba.png?size=40px
:target: https://github.com/PicchiSeba
:alt: PicchiSeba

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-aleuffre| |maintainer-renda-dev| |maintainer-PicchiSeba|

This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/14.0/partner_sequence_address_type>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions partner_sequence_address_type/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .hooks import post_init_hook
22 changes: 22 additions & 0 deletions partner_sequence_address_type/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Partner Sequence Address Type",
"version": "14.0.1.0.0",
"depends": [
"base_partner_sequence",
"contacts",
],
"author": "PyTech SRL, Ooops404, Odoo Community Association (OCA)",
"maintainers": ["aleuffre", "renda-dev", "PicchiSeba"],
"website": "https://github.com/OCA/partner-contact",
"category": "Partner Management",
"license": "AGPL-3",
"data": [
"security/ir.model.access.csv",
"views/ir_sequence_views.xml",
"views/res_partner_views.xml",
],
"installable": True,
"application": False,
"post_init_hook": "post_init_hook",
"uninstall_hook": "uninstall_hook",
}
17 changes: 17 additions & 0 deletions partner_sequence_address_type/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from odoo import SUPERUSER_ID, api


def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
partner_types = env["res.partner"]._fields.get("type").selection
partner_types.append((False, "No address type set"))

env["res.partner.sequence.type"].create(
[
{
"name": v,
"code": k,
}
for k, v in dict(partner_types).items()
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_sequence_address_type
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.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_sequence_address_type
#: model:ir.model.fields,field_description:partner_sequence_address_type.field_res_partner_sequence_type__code
msgid "Code"
msgstr ""

#. module: partner_sequence_address_type
#: model:ir.model,name:partner_sequence_address_type.model_res_partner
msgid "Contact"
msgstr ""

#. module: partner_sequence_address_type
#: model:ir.model.fields,field_description:partner_sequence_address_type.field_res_partner_sequence_type__create_uid
msgid "Created by"
msgstr ""

#. module: partner_sequence_address_type
#: model:ir.model.fields,field_description:partner_sequence_address_type.field_res_partner_sequence_type__create_date
msgid "Created on"
msgstr ""

#. module: partner_sequence_address_type
#: model:ir.model.fields,field_description:partner_sequence_address_type.field_res_partner__display_name
#: model:ir.model.fields,field_description:partner_sequence_address_type.field_res_partner_sequence_type__display_name
msgid "Display Name"
msgstr ""

#. module: partner_sequence_address_type
#: model:ir.model.fields,field_description:partner_sequence_address_type.field_res_partner__id
#: model:ir.model.fields,field_description:partner_sequence_address_type.field_res_partner_sequence_type__id
msgid "ID"
msgstr ""

#. module: partner_sequence_address_type
#: model:ir.model.fields,field_description:partner_sequence_address_type.field_res_partner____last_update
#: model:ir.model.fields,field_description:partner_sequence_address_type.field_res_partner_sequence_type____last_update
msgid "Last Modified on"
msgstr ""

#. module: partner_sequence_address_type
#: model:ir.model.fields,field_description:partner_sequence_address_type.field_res_partner_sequence_type__write_uid
msgid "Last Updated by"
msgstr ""

#. module: partner_sequence_address_type
#: model:ir.model.fields,field_description:partner_sequence_address_type.field_res_partner_sequence_type__write_date
msgid "Last Updated on"
msgstr ""

#. module: partner_sequence_address_type
#: model:ir.model.fields,field_description:partner_sequence_address_type.field_res_partner_sequence_type__name
msgid "Name"
msgstr ""

#. module: partner_sequence_address_type
#: model:ir.model,name:partner_sequence_address_type.model_res_partner_sequence_type
msgid "Partner Sequence Type"
msgstr ""

#. module: partner_sequence_address_type
#: model:ir.actions.act_window,name:partner_sequence_address_type.res_partner_sequence_type_action
#: model:ir.ui.menu,name:partner_sequence_address_type.menu_res_partner_sequence_type_action
msgid "Partner Sequence by Address Type"
msgstr ""

#. module: partner_sequence_address_type
#: model:ir.model.fields,field_description:partner_sequence_address_type.field_res_partner_sequence_type__sequence_id
msgid "Sequence"
msgstr ""
2 changes: 2 additions & 0 deletions partner_sequence_address_type/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import res_partner
from . import res_partner_sequence_type
42 changes: 42 additions & 0 deletions partner_sequence_address_type/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from odoo import api, models


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

def _get_next_ref(self, vals=None):
"""
Get the next reference according to the
selected address type
Still call super() to preserve the stack
"""
super()._get_next_ref()

partner_type = vals.get("type", self.type) if vals else self.type
partner_sequence_id = self.env["res.partner.sequence.type"].search(
[("code", "=", partner_type)]
)
return (
partner_sequence_id.sequence_id.next_by_id()
if partner_sequence_id.sequence_id
else False
)

def _needs_ref(self, vals=None):
"""
Return true even if it has a parent_id,
or it's not a company
Still call super() to preserve the stack
"""
super()._needs_ref(vals)
return True

@api.model
def _commercial_fields(self):
"""
Don't make the partner reference a field that is propagated
to the partner's contacts
"""
return [i for i in super(ResPartner, self)._commercial_fields() if i != "ref"]
11 changes: 11 additions & 0 deletions partner_sequence_address_type/models/res_partner_sequence_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from odoo import fields, models


class ResPartnerSequenceType(models.Model):
_name = "res.partner.sequence.type"
_description = "Partner Sequence Type"

name = fields.Char(readonly=True, required=True)
code = fields.Char(readonly=True)

sequence_id = fields.Many2one("ir.sequence")
5 changes: 5 additions & 0 deletions partner_sequence_address_type/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* `PyTech SRL <https://www.pytech.it>`__:

* Alessio Renda

* `Ooops404 <https://www.ooops404.com>`__
7 changes: 7 additions & 0 deletions partner_sequence_address_type/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This module allows to use different sequences to generate values for Reference field in partner, according to their address type.


It also makes Reference field visible when opening records from "Contacts & Addresses" kanban cards.


Please note: in this module child contacts do not inherit Reference value from parent contact, and value of field Reference is never read-only.
3 changes: 3 additions & 0 deletions partner_sequence_address_type/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Users with access rights Administration: access rights can access menu "Partner Sequence by Address Type" from Contacts > Configuration and set a sequence for each address type.

Address types without sequence will not have a Reference value assigned automatically.
3 changes: 3 additions & 0 deletions partner_sequence_address_type/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_res_partner_sequence_type_manager,access_res_partner_sequence_type_manager,model_res_partner_sequence_type,base.group_erp_manager,1,1,0,0
access_res_partner_sequence_type_public,access_res_partner_sequence_type_public,model_res_partner_sequence_type,base.group_user,1,0,0,0
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 7e5e935

Please sign in to comment.