Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] l10n_us_partner_name: Create module
* Add `partner-contact` to OCA depends * Reverse ordering of first and last names provided by `partner_firstname`
- Loading branch information
Showing
8 changed files
with
141 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
|
||
==================== | ||
l10n US Partner Name | ||
==================== | ||
|
||
Use American conventions for partner names: | ||
|
||
* Split first and last names (provided by ``partner_firstname``) | ||
* Display name as ``Firstname Lastname`` | ||
|
||
|
||
Usage | ||
===== | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/203/10.0 | ||
|
||
For further information, please visit: | ||
|
||
* https://www.odoo.com/forum/help-1 | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
|
||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/l10n-usa/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. | ||
|
||
|
||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Dave Lasley <dave@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 http://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 LasLabs Inc. | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 LasLabs Inc. | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
from . import res_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 LasLabs Inc. | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
|
||
_inherit = 'res.partner' | ||
|
||
@api.model | ||
def _get_computed_name(self, lastname, firstname): | ||
return u" ".join((p for p in (firstname, lastname) if p)) | ||
|
||
@api.model | ||
def _get_inverse_name(self, name, is_company=False): | ||
""" It reverses the results of the super to provide ``First Last`` """ | ||
result = super(ResPartner, self)._get_inverse_name( | ||
name, is_company=is_company, | ||
) | ||
result.update({ | ||
'firstname': result['lastname'], | ||
'lastname': result['firstname'], | ||
}) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 LasLabs Inc. | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
from . import test_res_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 LasLabs Inc. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestResPartner(TransactionCase): | ||
|
||
def setUp(self): | ||
super(TestResPartner, self).setUp() | ||
self.first_name = 'Dave' | ||
self.last_name = 'Lasley' | ||
self.partner = self.env['res.partner'].create({ | ||
'name': '%s %s' % (self.first_name, self.last_name), | ||
}) | ||
|
||
def test_get_inverse_name_firstname(self): | ||
""" It should properly set firstname on partner """ | ||
self.assertEqual( | ||
self.partner.firstname, self.first_name, | ||
) | ||
|
||
def test_get_inverse_name_lastname(self): | ||
""" It should properly set lastname on partner """ | ||
self.assertEqual( | ||
self.partner.lastname, self.last_name, | ||
) | ||
|
||
def test_get_computed_name(self): | ||
""" It should compute name as `Firstname Lastname` """ | ||
self.assertEqual( | ||
self.partner.name, | ||
'%s %s' % (self.first_name, self.last_name), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1 @@ | ||
# List the OCA project dependencies, one per line | ||
# Add a repository url and branch if you need a forked version | ||
# | ||
# Examples | ||
# ======== | ||
# | ||
# To depend on the standard version of sale-workflow, use: | ||
# sale-workflow | ||
# | ||
# To explicitely give the URL of a fork, and still use the version specified in | ||
# .travis.yml, use: | ||
# sale-workflow https://github.com/OCA/sale-workflow | ||
# | ||
# To provide both the URL and a branch, use: | ||
# sale-workflow https://github.com/OCA/sale-workflow branchname | ||
partner-contact |