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

[12.0] Improvements for base_partner_ref #127

Open
wants to merge 4 commits into
base: 12.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
61 changes: 61 additions & 0 deletions base_partner_ref/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
======================
Base Partner Reference
======================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-Akretion%2FOdoo--Usability-lightgray.png?logo=github
:target: https://github.com/Akretion/Odoo-Usability/tree/12.0/base_partner_ref
:alt: Akretion/Odoo-Usability

|badge1| |badge2| |badge3|

Improve usage of partner's Internal Reference, this module adds the following functions:
- Adds Internal Reference in partner tree view
- Adds Internal Reference in name_get()
- Adds unicity constraint on Internal Reference

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/Akretion/Odoo-Usability/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/Akretion/Odoo-Usability/issues/new?body=module:%20base_partner_ref%0Aversion:%2012.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
~~~~~~~

* Akretion

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

* Alexis de Lattre <[email protected]>
* Renato Lima <[email protected]>

Maintainers
~~~~~~~~~~~

This module is part of the `Akretion/Odoo-Usability <https://github.com/Akretion/Odoo-Usability/tree/12.0/base_partner_ref>`_ project on GitHub.

You are welcome to contribute.
5 changes: 4 additions & 1 deletion base_partner_ref/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
from . import partner
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
from . import tests
4 changes: 3 additions & 1 deletion base_partner_ref/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['base'],
'data': ['partner_view.xml'],
'data': [
'views/partner.xml',
],
'installable': True,
}
3 changes: 3 additions & 0 deletions base_partner_ref/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import partner
25 changes: 16 additions & 9 deletions base_partner_ref/partner.py → base_partner_ref/models/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@
# @author: Alexis de Lattre <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
from odoo import _, api, fields, models


class ResPartner(models.Model):
_inherit = 'res.partner'

ref = fields.Char(copy=False) # To avoid blocking duplicate
ref = fields.Char(
copy=False, # To avoid blocking duplicate
)

invalidate_display_name = fields.Boolean()

_sql_constraints = [(
'ref_unique',
'unique(ref)',
'A partner already exists with this internal reference!'
)]
_('A partner already exists with this internal reference !')
)]

# add 'ref' in depends
@api.depends('is_company', 'name', 'parent_id.name', 'type', 'company_name', 'ref', 'invalidate_display_name')
@api.depends('is_company', 'name', 'parent_id.name', 'type',
'company_name', 'ref', 'invalidate_display_name')
def _compute_display_name(self):
super(ResPartner, self)._compute_display_name()
super()._compute_display_name()

def _get_name(self):
partner = self
Expand All @@ -32,12 +36,15 @@ def _get_name(self):
# END modif of native method
if partner.company_name or partner.parent_id:
if not name and partner.type in ['invoice', 'delivery', 'other']:
name = dict(self.fields_get(['type'])['type']['selection'])[partner.type]
name = dict(self.fields_get(
['type'])['type']['selection'])[partner.type]
if not partner.is_company:
# START modif of native name_get() method
company_name = partner.commercial_company_name or partner.parent_id.name
company_name = (
partner.commercial_company_name or partner.parent_id.name)
if partner.parent_id.ref:
company_name = u"[%s] %s" % (partner.parent_id.ref, company_name)
company_name = u"[%s] %s" % (
partner.parent_id.ref, company_name)
name = "%s, %s" % (company_name, name)
# END modif of native name_get() method
if self._context.get('show_address_only'):
Expand Down
2 changes: 2 additions & 0 deletions base_partner_ref/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Alexis de Lattre <[email protected]>
* Renato Lima <[email protected]>
4 changes: 4 additions & 0 deletions base_partner_ref/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Improve usage of partner's Internal Reference, this module adds the following functions:
- Adds Internal Reference in partner tree view
- Adds Internal Reference in name_get()
- Adds unicity constraint on Internal Reference
Binary file added base_partner_ref/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