Skip to content

Commit

Permalink
[17.0][ADD] partner_title_active
Browse files Browse the repository at this point in the history
  • Loading branch information
yankinmax committed Nov 1, 2024
1 parent f53d667 commit d057e9f
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 0 deletions.
78 changes: 78 additions & 0 deletions partner_title_active/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
====================
Partner title active
====================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2f8e19fa2b5e1e012ce7d31860053bc5b9e15bf4704d7dc64d30cbe0fbf61f2b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/17.0/partner_title_active
: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-17-0/partner-contact-17-0-partner_title_active
: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=17.0
:alt: Try me on Runboat

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

Adds an ``Active`` field to the partner title model to be able to deactivate titles without deleting them

**Table of contents**

.. contents::
:local:

Usage
=====

Archive/unarchive partner titles.

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_title_active%0Aversion:%2017.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
=======

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

- ``Camptocamp <https://www.camptocamp.com>``\ \_\_:

- Maksym Yankin [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/17.0/partner_title_active>`_ 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_title_active/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions partner_title_active/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Partner Title Active",
"version": "17.0.1.0.0",
"author": "Odoo Community Association (OCA), Camptocamp",
"license": "AGPL-3",
"category": "Contact",
"depends": [
# Odoo/core
"base",
],
"website": "https://github.com/OCA/partner-contact",
"data": [
"views/res_partner_title.xml",
],
"installable": True,
}
1 change: 1 addition & 0 deletions partner_title_active/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_partner_title
13 changes: 13 additions & 0 deletions partner_title_active/models/res_partner_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


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

active = fields.Boolean(
default=True,
help="The active field allows you to hide the title without removing it.",
)
3 changes: 3 additions & 0 deletions partner_title_active/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_title_active/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_partner_title
25 changes: 25 additions & 0 deletions partner_title_active/tests/test_partner_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo.tests.common import TransactionCase


class TestPartnerTitle(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.Partner = cls.env["res.partner"]
cls.PartnerTitle = cls.env["res.partner"]
cls.partner_title = cls.PartnerTitle.create(
{"name": "Ambassador", "shortcut": "Amb."}
)
cls.partner = cls.Partner.create(
{"name": "A Partner", "title": cls.partner_title.id}
)

def test_01_partner_title(self):
self.assertTrue(self.partner.title.active, "Title should be active by default")
self.partner_title.action_archive()
self.assertFalse(
self.partner.title.active, "Title should be inactive after archiving"
)
49 changes: 49 additions & 0 deletions partner_title_active/views/res_partner_title.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_partner_title_tree" model="ir.ui.view">
<field name="model">res.partner.title</field>
<field name="inherit_id" ref="base.view_partner_title_tree" />
<field name="arch" type="xml">
<field name="shortcut" position="after">
<field name="active" widget="boolean_toggle" />
</field>
</field>
</record>
<record id="view_partner_title_form" model="ir.ui.view">
<field name="model">res.partner.title</field>
<field name="inherit_id" ref="base.view_partner_title_form" />
<field name="arch" type="xml">
<group position="before">
<widget
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
invisible="active"
/>
</group>
<field name="name" position="before">
<field name="active" invisible="1" />
</field>
</field>
</record>
<record id="view_partner_title_search" model="ir.ui.view">
<field name="name">res.partner.title.search</field>
<field name="model">res.partner.title</field>
<field name="arch" type="xml">
<search string="Search Partner Titles">
<field name="name" />
<field name="shortcut" />
<separator />
<filter
string="Archived"
name="inactive"
domain="[('active', '=', False)]"
/>
</search>
</field>
</record>
</odoo>

0 comments on commit d057e9f

Please sign in to comment.