Browse Source

[NEW] add partner favorite mecanism

nj-12.0-partner_gogocarto_export_api
default 4 years ago
parent
commit
1353e0dfc1
  1. 1
      partner_favorite/__init__.py
  2. 21
      partner_favorite/__manifest__.py
  3. 45
      partner_favorite/i18n/fr.po
  4. 1
      partner_favorite/models/__init__.py
  5. 39
      partner_favorite/models/res_partner.py
  6. 1
      partner_favorite/readme/CONFIGURE.rst
  7. 1
      partner_favorite/readme/CONTRIBUTORS.rst
  8. 2
      partner_favorite/readme/DESCRIPTION.rst
  9. 1
      partner_favorite/readme/ROADMAP.rst
  10. 1
      partner_favorite/readme/USAGE.rst
  11. BIN
      partner_favorite/static/description/icon.png
  12. 31
      partner_favorite/views/res_partner.xml

1
partner_favorite/__init__.py

@ -0,0 +1 @@
from . import models

21
partner_favorite/__manifest__.py

@ -0,0 +1,21 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Partner Favorite',
'summary': "Add favorite star on Partner, and filter for favorite",
'version': '12.0.1.1.0',
'author': "Nicolas JEUDY, "
"Myceliandre, "
"Lokavaluto, "
"Odoo Community Association (OCA)",
'license': "AGPL-3",
'maintainer': 'Nicolas JEUDY',
'category': 'Extra Tools',
'website': 'https://odoo-community.org/',
'depends': ['base'],
'data': [
'views/res_partner.xml',
],
'auto_install': False,
'installable': True,
}

45
partner_favorite/i18n/fr.po

@ -0,0 +1,45 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_favorite
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-10 20:53+0000\n"
"PO-Revision-Date: 2021-05-10 20:53+0000\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_favorite
#: model:ir.model,name:partner_favorite.model_res_partner
msgid "Contact"
msgstr "Contact"
#. module: partner_favorite
#: model:ir.model.fields,help:partner_favorite.field_res_partner__is_favorite
#: model:ir.model.fields,help:partner_favorite.field_res_users__is_favorite
msgid "Display this partner with favorite filter"
msgstr "Afficher les partenaires favoris"
#. module: partner_favorite
#: model:ir.model.fields,field_description:partner_favorite.field_res_partner__favorite_user_ids
#: model:ir.model.fields,field_description:partner_favorite.field_res_users__favorite_user_ids
msgid "Members"
msgstr "Membres"
#. module: partner_favorite
#: model_terms:ir.ui.view,arch_db:partner_favorite.view_partner_search_favorite
msgid "My Favorites"
msgstr "Mes favoris"
#. module: partner_favorite
#: model:ir.model.fields,field_description:partner_favorite.field_res_partner__is_favorite
#: model:ir.model.fields,field_description:partner_favorite.field_res_users__is_favorite
msgid "Show Favorite Partner"
msgstr "Afficher les partenaire favoris"

1
partner_favorite/models/__init__.py

@ -0,0 +1 @@
from . import res_partner

39
partner_favorite/models/res_partner.py

@ -0,0 +1,39 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from odoo import fields, models
_logger = logging.getLogger(__name__)
class ResPartner(models.Model):
"""Adds last name and first name; name becomes a stored function field."""
_inherit = 'res.partner'
def _compute_is_favorite(self):
for partner in self:
partner.is_favorite = self.env.user in partner.favorite_user_ids
def _inverse_is_favorite(self):
favorite_partners = not_fav_partners = self.env['res.partner'].sudo()
for partner in self:
if self.env.user in partner.favorite_user_ids:
favorite_partners |= partner
else:
not_fav_partners |= partner
# partner User has no write access for partner.
not_fav_partners.write({'favorite_user_ids': [(4, self.env.uid)]})
favorite_partners.write({'favorite_user_ids': [(3, self.env.uid)]})
def _get_default_favorite_user_ids(self):
return [(6, 0, [self.env.uid])]
favorite_user_ids = fields.Many2many(
'res.users', 'partner_favorite_user_rel', 'partner_id', 'user_id',
default=_get_default_favorite_user_ids,
string='Members')
is_favorite = fields.Boolean(
compute='_compute_is_favorite',
inverse='_inverse_is_favorite',
string='Show Favorite Partner',
help="Display this partner with favorite filter")

1
partner_favorite/readme/CONFIGURE.rst

@ -0,0 +1 @@
N/A

1
partner_favorite/readme/CONTRIBUTORS.rst

@ -0,0 +1 @@
* Nicolas JEUDY <https://github.com/njeudy>

2
partner_favorite/readme/DESCRIPTION.rst

@ -0,0 +1,2 @@
This module was written to extend the functionality of contacts to support
having favorite mechanism.

1
partner_favorite/readme/ROADMAP.rst

@ -0,0 +1 @@
* add filters

1
partner_favorite/readme/USAGE.rst

@ -0,0 +1 @@
After installing this module you can select a partner as favorite and filter on "My favorite".

BIN
partner_favorite/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

31
partner_favorite/views/res_partner.xml

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_partner_form_favorite" model="ir.ui.view">
<field name="name">Add favorite star</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.res_partner_kanban_view"/>
<field name="arch" type="xml">
<data>
<field name="type" position="after">
<field name="is_favorite"/>
</field>
<xpath expr="//strong/field[@name='display_name']" position="before">
<span class="o_right"><field name="is_favorite" widget="boolean_favorite" nolabel="1" force_save="1" /></span>
</xpath>
</data>
</field>
</record>
<record id="view_partner_search_favorite" model="ir.ui.view">
<field name="name">Add favorite star</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter"/>
<field name="arch" type="xml">
<data>
<filter name="filter_my_partners" position="after">
<filter string="My Favorites" name="my_partners" domain="[('favorite_user_ids', 'in', uid)]"/>
</filter>
</data>
</field>
</record>
</odoo>
Loading…
Cancel
Save