Browse Source
[ADD] partner_alias: Add module.
[ADD] partner_alias: Add module.
* Extends res partner with firstname aliasespull/382/head
Brett Wood
8 years ago
14 changed files with 295 additions and 0 deletions
-
60partner_alias/README.rst
-
5partner_alias/__init__.py
-
28partner_alias/__manifest__.py
-
17partner_alias/demo/res_partner_alias_demo.xml
-
12partner_alias/demo/res_partner_demo.xml
-
6partner_alias/models/__init__.py
-
16partner_alias/models/res_partner.py
-
41partner_alias/models/res_partner_alias.py
-
0partner_alias/security/ir.model.access.csv
-
BINpartner_alias/static/description/icon.png
-
5partner_alias/tests/__init__.py
-
27partner_alias/tests/test_partner_alias.py
-
52partner_alias/views/res_partner_alias_view.xml
-
26partner_alias/views/res_partner_view.xml
@ -0,0 +1,60 @@ |
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
|||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
============= |
|||
Partner Alias |
|||
============= |
|||
|
|||
This module extends partners with the concepts of aliases. |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
* Simply navigate to the form view of the partner, click on `Personal Information` |
|||
(only visible if the partner is an individual), and the alias attributes are below. |
|||
|
|||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
|||
:alt: Try me on Runbot |
|||
:target: https://runbot.odoo-community.org/runbot/134/10.0 |
|||
|
|||
Known issues / Roadmap |
|||
====================== |
|||
|
|||
* Upgrade One2many alias_ids tree to tags when One2many tags module available. |
|||
|
|||
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 smash it by providing detailed and welcomed feedback. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Images |
|||
------ |
|||
|
|||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Brett Wood <bwood@laslabs.com> |
|||
|
|||
Maintainer |
|||
---------- |
|||
|
|||
.. image:: https://odoo-community.org/logo.png |
|||
:alt: Odoo Community Association |
|||
:target: https://odoo-community.org |
|||
|
|||
This module is maintained by the OCA. |
|||
|
|||
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. |
|||
|
|||
To contribute to this module, please visit https://odoo-community.org. |
@ -0,0 +1,5 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016-2017 LasLabs Inc. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import models |
@ -0,0 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016-2017 LasLabs Inc. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
{ |
|||
"name": "Partner Alias", |
|||
"summary": "Adds aliases to partner names.", |
|||
"version": "10.0.1.0.0", |
|||
"category": "Contacts", |
|||
"website": "https://laslabs.com", |
|||
"author": "Laslabs, Odoo Community Association (OCA)", |
|||
"license": "AGPL-3", |
|||
"application": False, |
|||
"installable": True, |
|||
"depends": [ |
|||
"partner_contact_personal_information_page", |
|||
"partner_firstname", |
|||
], |
|||
"data": [ |
|||
# "security/ir.model.access.csv", |
|||
"views/res_partner_view.xml", |
|||
"views/res_partner_alias_view.xml", |
|||
], |
|||
"demo": [ |
|||
"demo/res_partner_demo.xml", |
|||
"demo/res_partner_alias_demo.xml", |
|||
], |
|||
} |
@ -0,0 +1,17 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- Copyright 2016-2017 LasLabs Inc. |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
|||
|
|||
<odoo> |
|||
|
|||
<record id="res_partner_alias_alias_1" model="res.partner.alias"> |
|||
<field name="firstname">Phillip</field> |
|||
<field name="partner_id" ref="res_partner_partner_malcom" /> |
|||
</record> |
|||
|
|||
<record id="res_partner_alias_alias_2" model="res.partner.alias"> |
|||
<field name="firstname">Greg</field> |
|||
<field name="partner_id" ref="res_partner_partner_malcom" /> |
|||
</record> |
|||
|
|||
</odoo> |
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- Copyright 2016-2017 LasLabs Inc. |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
|||
|
|||
<odoo> |
|||
|
|||
<record id="res_partner_partner_malcom" model="res.partner"> |
|||
<field name="firstname">Malcom</field> |
|||
<field name="lastname">Widdleton</field> |
|||
</record> |
|||
|
|||
</odoo> |
@ -0,0 +1,6 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016-2017 LasLabs Inc. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import res_partner |
|||
from . import res_partner_alias |
@ -0,0 +1,16 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016-2017 LasLabs Inc. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import fields, models |
|||
|
|||
|
|||
class ResPartner(models.Model): |
|||
|
|||
_inherit = 'res.partner' |
|||
|
|||
alias_ids = fields.One2many( |
|||
string='Aliases', |
|||
comodel_name='res.partner.alias', |
|||
inverse_name='partner_id', |
|||
) |
@ -0,0 +1,41 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016-2017 LasLabs Inc. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import api, fields, models, _ |
|||
from odoo.exceptions import ValidationError |
|||
|
|||
|
|||
class ResPartnerAlias(models.Model): |
|||
|
|||
_inherits = {'res.partner': 'partner_id'} |
|||
_name = 'res.partner.alias' |
|||
_description = 'Res Partner Alias' |
|||
|
|||
partner_id = fields.Many2one( |
|||
string='Related Partner', |
|||
comodel_name='res.partner', |
|||
required=True, |
|||
ondelete='cascade', |
|||
index=True, |
|||
) |
|||
firstname = fields.Char( |
|||
string='First Name', |
|||
required=True, |
|||
) |
|||
|
|||
@api.multi |
|||
@api.constrains('firstname') |
|||
def _check_firstname(self): |
|||
for record in self: |
|||
if record.firstname == record.partner_id.firstname: |
|||
raise ValidationError(_( |
|||
'Alias first name cannot be the same as ' |
|||
'primary firstname' |
|||
)) |
|||
|
|||
_sql_constraints = [ |
|||
('alias_name_uniq', |
|||
'UNIQUE(firstname)', |
|||
'Alias first name must be unique'), |
|||
] |
After Width: 128 | Height: 128 | Size: 9.2 KiB |
@ -0,0 +1,5 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016-2017 LasLabs Inc. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import test_partner_alias |
@ -0,0 +1,27 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016-2017 LasLabs Inc. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo.tests.common import TransactionCase |
|||
|
|||
from odoo.exceptions import ValidationError |
|||
from psycopg2 import IntegrityError |
|||
|
|||
|
|||
class TestPartnerAlias(TransactionCase): |
|||
|
|||
def setUp(self): |
|||
super(TestPartnerAlias, self).setUp() |
|||
self.alias_1 = self.env.ref( |
|||
'partner_alias.res_partner_alias_alias_1' |
|||
) |
|||
|
|||
def test_check_name(self): |
|||
""" Test raise ValidationError if alias name same as partner """ |
|||
with self.assertRaises(ValidationError): |
|||
self.alias_1.firstname = 'Malcom' |
|||
|
|||
def test_unique_name(self): |
|||
""" Test raises IntegrityError is name not unique """ |
|||
with self.assertRaises(IntegrityError): |
|||
self.alias_1.firstname = 'Greg' |
@ -0,0 +1,52 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- Copyright 2016-2017 LasLabs Inc. |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
|||
|
|||
<odoo> |
|||
|
|||
<record id="res_partner_alias_view_tree" model="ir.ui.view"> |
|||
<field name="name">res.partner.alias.view.tree</field> |
|||
<field name="model">res.partner.alias</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="Partner Aliases"> |
|||
<field name="firstname" /> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="res_partner_alias_view_form" model="ir.ui.view"> |
|||
<field name="name">res.partner.alias.view.form</field> |
|||
<field name="model">res.partner.alias</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Partner Alias"> |
|||
<group> |
|||
<group> |
|||
<field name="firstname" /> |
|||
</group> |
|||
</group> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="res_partner_alias_view_search" model="ir.ui.view"> |
|||
<field name="name">res.partner.alias.view.search</field> |
|||
<field name="model">res.partner.alias</field> |
|||
<field name="arch" type="xml"> |
|||
<search string="Partner Aliases"> |
|||
<field name="firstname" /> |
|||
</search> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="res_partner_alias_action" model="ir.actions.act_window"> |
|||
<field name="name">Aliases</field> |
|||
<field name="type">ir.actions.act_window</field> |
|||
<field name="res_model">res.partner.alias</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
<field name="search_view_id" ref="res_partner_alias_view_search" /> |
|||
<field name="domain">[]</field> |
|||
<field name="context">{}</field> |
|||
</record> |
|||
|
|||
</odoo> |
@ -0,0 +1,26 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- Copyright 2016-2017 LasLabs Inc. |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
|||
|
|||
<odoo> |
|||
|
|||
<record id="personal_information" model="ir.ui.view"> |
|||
<field name="name">Personal information page for contacts form</field> |
|||
<field name="model">res.partner</field> |
|||
<field name="inherit_id" ref="partner_contact_personal_information_page.personal_information" /> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//page[@name='personal_information_page']" position="inside"> |
|||
<group string="Aliases" name="aliases"> |
|||
<field name="alias_ids" nolabel="1"> |
|||
<tree editable="bottom" |
|||
context="{'default_partner_id': id}" |
|||
> |
|||
<field name="firstname" /> |
|||
</tree> |
|||
</field> |
|||
</group> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue