7 changed files with 171 additions and 0 deletions
-
79partner_legal_name/README.rst
-
1partner_legal_name/__init__.py
-
16partner_legal_name/__manifest__.py
-
1partner_legal_name/model/__init__.py
-
1partner_legal_name/model/base/__init__.py
-
55partner_legal_name/model/base/res_partner.py
-
18partner_legal_name/view/base/res_partner_view.xml
@ -0,0 +1,79 @@ |
|||
=========== |
|||
Partner Legal name |
|||
=========== |
|||
|
|||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|||
!! 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-OCA%2Fpartner--contact-lightgray.png?logo=github |
|||
:target: https://github.com/OCA/partner-contact/tree/12.0/partner_fax |
|||
: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-12-0/partner-contact-12-0-partner_fax |
|||
:alt: Translate me on Weblate |
|||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png |
|||
:target: https://runbot.odoo-community.org/runbot/134/12.0 |
|||
:alt: Try me on Runbot |
|||
|
|||
|badge1| |badge2| |badge3| |badge4| |badge5| |
|||
|
|||
This module adds a legal_name field into the partner form and assign value of display_name = legal_name. |
|||
|
|||
|
|||
**Table of contents** |
|||
|
|||
.. contents:: |
|||
:local: |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
To use this module, you need to: |
|||
|
|||
1. Go to the partner form |
|||
2. There you will see a new field called "Legal Name" that you can use to save the partner's Legal Name |
|||
3. For tree view, you can also see legal_name's values, if there is a many2one field which link with 'res.partner' |
|||
|
|||
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 smashing it by providing a detailed and welcomed |
|||
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_fax%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 |
|||
======= |
|||
|
|||
Contributors |
|||
~~~~~~~~~~~~ |
|||
|
|||
* Truong Dinh Minh Duc |
|||
* ductdm <duc.tdm@komit-consulting.com> |
|||
|
|||
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/12.0/partner_fax>`_ project on GitHub. |
|||
|
|||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
@ -0,0 +1 @@ |
|||
from . import model |
@ -0,0 +1,16 @@ |
|||
{ |
|||
'name': 'Partner Legal Name', |
|||
'version': '12.0.1.0.0', |
|||
'installable': True, |
|||
'category': 'base', |
|||
'author': 'Komit', |
|||
'website': 'http://komit-consulting.com', |
|||
'license': 'AGPL-3', |
|||
"depends": [ |
|||
'base' |
|||
], |
|||
"data": [ |
|||
'view/base/res_partner_view.xml' |
|||
], |
|||
"application": True |
|||
} |
@ -0,0 +1 @@ |
|||
from . import base |
@ -0,0 +1 @@ |
|||
from . import res_partner |
@ -0,0 +1,55 @@ |
|||
from odoo import api, fields, models, _ |
|||
|
|||
|
|||
class ResPartner(models.Model): |
|||
_inherit = "res.partner" |
|||
|
|||
legal_name = fields.Char() |
|||
|
|||
@api.onchange('name') |
|||
def onchange_legal_name(self): |
|||
if self.legal_name == '': |
|||
self.legal_name = self.name |
|||
|
|||
@api.multi |
|||
def name_get(self): |
|||
res = [] |
|||
for partner in self: |
|||
name_legal = partner._get_name() |
|||
res.append((partner.id, name_legal)) |
|||
return res |
|||
|
|||
def _get_name(self): |
|||
partner = self |
|||
name = partner.legal_name or '' |
|||
|
|||
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] |
|||
if not partner.is_company: |
|||
name = \ |
|||
"%s, %s" % (partner.commercial_company_name or |
|||
partner.parent_id.legal_name, name) |
|||
if self._context.get('show_address_only'): |
|||
name = partner._display_address(without_company=True) |
|||
if self._context.get('show_address'): |
|||
name = name + "\n" + partner._display_address(without_company=True) |
|||
name = name.replace('\n\n', '\n') |
|||
name = name.replace('\n\n', '\n') |
|||
if self._context.get('address_inline'): |
|||
name = name.replace('\n', ', ') |
|||
if self._context.get('show_email') and partner.email: |
|||
name = "%s <%s>" % (name, partner.email) |
|||
if self._context.get('html_format'): |
|||
name = name.replace('\n', '<br/>') |
|||
if self._context.get('show_vat') and partner.vat: |
|||
name = "%s - %s" % (name, partner.vat) |
|||
return name |
|||
|
|||
@api.depends('is_company', 'legal_name', 'parent_id.name', |
|||
'type', 'company_name') |
|||
def _compute_display_name(self): |
|||
for partner in self: |
|||
partner.display_name = partner.legal_name |
@ -0,0 +1,18 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
|
|||
<record id="view_partner_form_inherit" model="ir.ui.view"> |
|||
<field name="name">view_partner_form_inherit</field> |
|||
<field name="model">res.partner</field> |
|||
<field name="view_mode">form,tree</field> |
|||
<field name="inherit_id" ref="base.view_partner_form"/> |
|||
<field name="arch" type="xml"> |
|||
<field name="name" position="after"> |
|||
<div style="font-weight:normal"> |
|||
<field name="legal_name" string="Legal name" readonly="False"/> |
|||
</div> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue