forked from OCA/partner-contact
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1153 from OCA/14.0
Syncing from upstream OCA/partner-contact (14.0)
- Loading branch information
Showing
21 changed files
with
813 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from .hooks import post_init_hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
] | ||
) |
83 changes: 83 additions & 0 deletions
83
partner_sequence_address_type/i18n/partner_sequence_address_type.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import res_partner | ||
from . import res_partner_sequence_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
partner_sequence_address_type/models/res_partner_sequence_type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>`__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.