Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG][16.0] partner_industry_parent #1835

Open
wants to merge 15 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions partner_industry_parent/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
=======================
Partner Industry Parent
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:533942a290cb3171f2406a071fee77638b4f37cd103aa372a18bee93d19281cb
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/15.0/partner_industry_parent
: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-15-0/partner-contact-15-0-partner_industry_parent
: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=15.0
:alt: Try me on Runboat

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

This module add a parent relation to the partner industry

**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_industry_parent%0Aversion:%2015.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
~~~~~~~

* ACSONE SA/NV

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

* Souheil Bejaoui <souheil.bejaoui@acsone.eu>

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/15.0/partner_industry_parent>`_ 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_industry_parent/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions partner_industry_parent/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Partner Industry Parent",
"summary": """
This module add a parent relation to the partner industry""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/partner-contact",
"depends": ["base"],
"data": [
"views/res_partner_views.xml",
"views/res_partner_industry_views.xml",
],
"demo": [],
}
94 changes: 94 additions & 0 deletions partner_industry_parent/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_industry_parent
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-10-09 07:40+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: partner_industry_parent
#: model:ir.model.fields,field_description:partner_industry_parent.field_res_partner_industry__partner_count
msgid "# Partners"
msgstr "# Socios"

#. module: partner_industry_parent
#: model_terms:ir.ui.view,arch_db:partner_industry_parent.partner_industry_parent_form
msgid "<span class=\"o_stat_text\"> Partners</span>"
msgstr "<span class=\"o_stat_text\"> Socios</span>"

#. module: partner_industry_parent
#: model:ir.model.fields,field_description:partner_industry_parent.field_res_partner_industry__child_ids
msgid "Children"
msgstr "Niños"

#. module: partner_industry_parent
#: model:ir.model.fields,field_description:partner_industry_parent.field_res_partner_industry__complete_name
msgid "Complete Name"
msgstr "Nombre completo"

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

#. module: partner_industry_parent
#: model_terms:ir.actions.act_window,help:partner_industry_parent.action_partners_all
msgid "Create a new partner"
msgstr "Crear un nuevo socio"

#. module: partner_industry_parent
#: model:ir.model,name:partner_industry_parent.model_res_partner_industry
#: model_terms:ir.ui.view,arch_db:partner_industry_parent.partner_industry_parent_form
#: model_terms:ir.ui.view,arch_db:partner_industry_parent.view_res_partner_filter
msgid "Industry"
msgstr "Industria"

#. module: partner_industry_parent
#: model:ir.model.fields,field_description:partner_industry_parent.field_res_partner_industry__parent_id
msgid "Parent"
msgstr "Parental"

#. module: partner_industry_parent
#: model:ir.model.fields,field_description:partner_industry_parent.field_res_partner_industry__parent_path
msgid "Parent Path"
msgstr "Ruta parental"

#. module: partner_industry_parent
#: model:ir.actions.act_window,name:partner_industry_parent.action_partners_all
msgid "Partners"
msgstr "Socios"

#. module: partner_industry_parent
#: code:addons/partner_industry_parent/models/res_partner.py:0
#, python-format
msgid "Partners: %(industry)s"
msgstr "Socios: %(industry)s"

#. module: partner_industry_parent
#: model:ir.model.fields,help:partner_industry_parent.field_res_partner_industry__partner_count
msgid ""
"The number of partners under this industry (Does not consider the children "
"categories)"
msgstr ""
"Número de socios de este sector (No tiene en cuenta las categorías de niños)"

#. module: partner_industry_parent
#: code:addons/partner_industry_parent/models/res_partner_industry.py:0
#, python-format
msgid "You cannot create recursive categories."
msgstr "No puede crear categorías recursivas."

#. module: partner_industry_parent
#: model_terms:ir.ui.view,arch_db:partner_industry_parent.partner_industry_parent_form
msgid "e.g. Health and care"
msgstr "p. ej. Sanidad y asistencia"
90 changes: 90 additions & 0 deletions partner_industry_parent/i18n/partner_industry_parent.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_industry_parent
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.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_industry_parent
#: model:ir.model.fields,field_description:partner_industry_parent.field_res_partner_industry__partner_count
msgid "# Partners"
msgstr ""

#. module: partner_industry_parent
#: model_terms:ir.ui.view,arch_db:partner_industry_parent.partner_industry_parent_form
msgid "<span class=\"o_stat_text\"> Partners</span>"
msgstr ""

#. module: partner_industry_parent
#: model:ir.model.fields,field_description:partner_industry_parent.field_res_partner_industry__child_ids
msgid "Children"
msgstr ""

#. module: partner_industry_parent
#: model:ir.model.fields,field_description:partner_industry_parent.field_res_partner_industry__complete_name
msgid "Complete Name"
msgstr ""

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

#. module: partner_industry_parent
#: model_terms:ir.actions.act_window,help:partner_industry_parent.action_partners_all
msgid "Create a new partner"
msgstr ""

#. module: partner_industry_parent
#: model:ir.model,name:partner_industry_parent.model_res_partner_industry
#: model_terms:ir.ui.view,arch_db:partner_industry_parent.partner_industry_parent_form
#: model_terms:ir.ui.view,arch_db:partner_industry_parent.view_res_partner_filter
msgid "Industry"
msgstr ""

#. module: partner_industry_parent
#: model:ir.model.fields,field_description:partner_industry_parent.field_res_partner_industry__parent_id
msgid "Parent"
msgstr ""

#. module: partner_industry_parent
#: model:ir.model.fields,field_description:partner_industry_parent.field_res_partner_industry__parent_path
msgid "Parent Path"
msgstr ""

#. module: partner_industry_parent
#: model:ir.actions.act_window,name:partner_industry_parent.action_partners_all
msgid "Partners"
msgstr ""

#. module: partner_industry_parent
#: code:addons/partner_industry_parent/models/res_partner.py:0
#, python-format
msgid "Partners: %(industry)s"
msgstr ""

#. module: partner_industry_parent
#: model:ir.model.fields,help:partner_industry_parent.field_res_partner_industry__partner_count
msgid ""
"The number of partners under this industry (Does not consider the children "
"categories)"
msgstr ""

#. module: partner_industry_parent
#: code:addons/partner_industry_parent/models/res_partner_industry.py:0
#, python-format
msgid "You cannot create recursive categories."
msgstr ""

#. module: partner_industry_parent
#: model_terms:ir.ui.view,arch_db:partner_industry_parent.partner_industry_parent_form
msgid "e.g. Health and care"
msgstr ""
2 changes: 2 additions & 0 deletions partner_industry_parent/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import res_partner_industry
from . import res_partner
54 changes: 54 additions & 0 deletions partner_industry_parent/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import SUPERUSER_ID, _, api, models


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

@api.model
def _search(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a minor point, I know you didn't write yourself, and purely opinion. I much prefer these overrides where only args is amended to use the idiom

def _search(args, **kwargs):
   # modify args code
  return super()._search(args, **kwargs)

It is loads shorter, more resistant to api changes, and cleaner for people to read as they know only args is being affected.

Then super()

self,
args,
offset=0,
limit=None,
order=None,
count=False,
access_rights_uid=None,
):
if self._context.get("search_default_industry_id"):
args.append(

Check warning on line 21 in partner_industry_parent/models/res_partner.py

View check run for this annotation

Codecov / codecov/patch

partner_industry_parent/models/res_partner.py#L21

Added line #L21 was not covered by tests
(
"industry_id",
"child_of",
self._context["search_default_industry_id"],
)
)
return super()._search(
args,
offset=offset,
limit=limit,
order=order,
count=count,
access_rights_uid=access_rights_uid,
)

@api.model
def view_header_get(self, view_id, view_type):
if self._context.get("industry_id"):
return _(

Check warning on line 40 in partner_industry_parent/models/res_partner.py

View check run for this annotation

Codecov / codecov/patch

partner_industry_parent/models/res_partner.py#L40

Added line #L40 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? I don't really know translations but I thought the rule was _(<format_string>), args not _(<format_string>, args)

"Partners: %(industry)s",
industry=self.env["res.partner.industry"]
.browse(self.env.context["industry_id"])
.name,
)
return super().view_header_get(view_id, view_type)

def _read_group_industry_id(self, industries, domain, order):
industry_ids = self.env.context.get("default_industry_id")

Check warning on line 49 in partner_industry_parent/models/res_partner.py

View check run for this annotation

Codecov / codecov/patch

partner_industry_parent/models/res_partner.py#L49

Added line #L49 was not covered by tests
if not industry_ids and self.env.context.get("group_expand"):
industry_ids = industries._search(

Check warning on line 51 in partner_industry_parent/models/res_partner.py

View check run for this annotation

Codecov / codecov/patch

partner_industry_parent/models/res_partner.py#L51

Added line #L51 was not covered by tests
[], order=order, access_rights_uid=SUPERUSER_ID
)
return industries.browse(industry_ids)

Check warning on line 54 in partner_industry_parent/models/res_partner.py

View check run for this annotation

Codecov / codecov/patch

partner_industry_parent/models/res_partner.py#L54

Added line #L54 was not covered by tests
Loading
Loading