Browse Source

Merge pull request #223 from gurneyalex/9.0-port_partner_address_street3

9.0 [MIG] port partner_address_street3
pull/231/merge
Pedro M. Baeza 9 years ago
parent
commit
ac1a865c1b
  1. 58
      partner_address_street3/README.rst
  2. 3
      partner_address_street3/__openerp__.py
  3. 30
      partner_address_street3/model/partner.py
  4. 32
      partner_address_street3/view/partner_view.xml

58
partner_address_street3/README.rst

@ -0,0 +1,58 @@
.. 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
===========================
3rd line on partner address
===========================
This module extends the base res.partner model by supplying a 3rd line on
addresses (`street3`)
.. 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/9.0
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:%20
partner_address_street3%0Aversion:%20
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Nicolas Bessi <nicolas.bessi@camptocamp.com>
* Alexandre Fayolle <alexandre.fayolle@camptocamp.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.

3
partner_address_street3/__openerp__.py

@ -26,12 +26,11 @@
'category': 'Sales',
'complexity': 'easy',
'depends': ['base'],
'description': """Add a third field to the address""",
'website': 'http://www.camptocamp.com',
'data': ['view/partner_view.xml'],
'demo': [],
'test': [],
'installable': False,
'installable': True,
'auto_install': False,
'license': 'AGPL-3',
'application': False,

30
partner_address_street3/model/partner.py

@ -2,7 +2,7 @@
##############################################################################
#
# Author: Nicolas Bessi
# Copyright 2014 Camptocamp SA
# Copyright 2014-2015 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -18,31 +18,31 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
from openerp import models, fields, api
class res_partner(orm.Model):
class ResPartner(models.Model):
"""Add third field in address"""
_inherit = "res.partner"
_columns = {
'street3': fields.char('Street 3'),
}
street3 = fields.Char('Street 3')
def _address_fields(self, cr, uid, context=None):
fields = super(res_partner, self
)._address_fields(cr, uid, context=context)
@api.model
def _address_fields(self):
fields = super(ResPartner, self)._address_fields()
fields.append('street3')
return fields
class res_country(orm.Model):
"""Override default adresses formatting of coutries"""
class res_country(models.Model):
"""Override default adresses formatting of countries"""
_inherit = 'res.country'
_defaults = {
'address_format': ("%(street)s\n%(street2)s\n%(street3)s\n"
address_format = fields.Text(
default=(
"%(street)s\n%(street2)s\n%(street3)s\n"
"%(city)s %(state_code)s %(zip)s\n"
"%(country_name)s"),
}
"%(country_name)s"
)
)

32
partner_address_street3/view/partner_view.xml

@ -7,18 +7,27 @@
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath
expr="//form[@string='Partners']/sheet/group/group/div/field[@name='street2']"
expr="/form/sheet/group/group/div/field[@name='street2']"
position="after">
<field name="street3"
attrs="{'readonly': [('use_parent_address','=',True)]}"/>
placeholder="Street 3..."
class="o_address_street"
attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
</xpath>
<xpath expr="//form[@string='Contact']/sheet/group/div/field[@name='street2']"
<xpath expr='//field[@name="child_ids"]' position="attributes">
<attribute name="context">{'default_parent_id': active_id,
'default_street': street, 'default_street2': street2,
'default_street3': street3, 'default_city': city, 'default_state_id':
state_id, 'default_zip': zip, 'default_country_id': country_id,
'default_supplier': supplier, 'default_customer': customer,
'default_lang': lang,}</attribute>
</xpath>
<xpath expr="/form//field[@name='child_ids']//field[@name='street2']"
position="after">
<field name="street3"/>
<field name="street3" placeholder="Street 3..." class="o_address_street"/>
</xpath>
<xpath expr="//kanban/field[@name='street2']"
<xpath expr="/form//field[@name='child_ids']/kanban/field[@name='street2']"
position="after">
<field name="street3"/>
</xpath>
@ -37,5 +46,16 @@
</field>
</record>
<record id="view_partner_address_form" model="ir.ui.view">
<field name="name">add street 3 in res.partner.form.address</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_address_form"/>
<field name="arch" type="xml">
<field name="street2" position="after">
<field name="street3" placeholder="Street 3..." class="o_address_street"/>
</field>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save