Skip to content

Commit

Permalink
[ADD] partner_type_base: improve partner type customizable
Browse files Browse the repository at this point in the history
  • Loading branch information
CRogos committed Nov 28, 2024
1 parent b270626 commit 1e5f26a
Show file tree
Hide file tree
Showing 13 changed files with 722 additions and 0 deletions.
77 changes: 77 additions & 0 deletions partner_type_base/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
=====================
Partner Address Types
=====================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:43d730c51ef59b1c6de4109020507234da1ada647d1a04e2b0bc1dc74dad4451
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_type_base
: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_type_base
: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|

This module was written to extend the functionality of contact types for
a flexible extension.

**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_type_base%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
-------

* CRogos

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

- Christopher Rogos

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_type_base>`_ 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_type_base/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions partner_type_base/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2013 Nicolas Bessi (Camptocamp SA)
# Copyright 2014 Agile Business Group (<http://www.agilebg.com>)
# Copyright 2015 Grupo ESOC (<http://www.grupoesoc.es>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Partner Address Types",
"summary": "Base implementation to improve the address type customization.",
"version": "18.0.1.0.0",
"author": "CRogos, Odoo Community Association (OCA)",
"license": "AGPL-3",
"maintainer": "glueckkanja AG",
"category": "Extra Tools",
"website": "https://github.com/OCA/partner-contact",
"depends": ["base_setup"],
"data": [
"views/res_partner.xml",
],
"auto_install": False,
"installable": True,
}
1 change: 1 addition & 0 deletions partner_type_base/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_partner
46 changes: 46 additions & 0 deletions partner_type_base/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2024 Christopher Rogos (<https://www.glueckkanja.com>)

from odoo import api, fields, models


class ResPartner(models.Model):
"""Adds last name and first name; name becomes a stored function field."""

_inherit = "res.partner"

is_address_readonly = fields.Boolean(
compute="_compute_contact_type",
help="If true, the address fields are readonly.",
)
is_individual = fields.Boolean(
compute="_compute_contact_type", help="If true, the partner name is splitted."
)
can_be_parent = fields.Boolean(
compute="_compute_contact_type",
search="_search_can_be_parent",
help="If true, the partner is available as parent.",
)
can_be_child = fields.Boolean(
compute="_compute_contact_type",
help="If true, the partner_id field is available.",
)

@api.depends("is_company", "type", "parent_id")
def _compute_contact_type(self):
for partner in self:
partner.is_address_readonly = not (
partner.is_company
or not partner.parent_id
or partner.type not in ["contact"]
)
partner.is_individual = not partner.is_company and partner.type in [
"contact",
"other",
]

partner.can_be_parent = partner.is_company
partner.can_be_child = not partner.is_company

@api.model
def _search_can_be_parent(self, operator, value):
return [("is_company", operator, value)]
3 changes: 3 additions & 0 deletions partner_type_base/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions partner_type_base/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Christopher Rogos
2 changes: 2 additions & 0 deletions partner_type_base/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module was written to extend the functionality of contact types
for a flexible extension.
Binary file added partner_type_base/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 1e5f26a

Please sign in to comment.