Andrea Stirpe
8 years ago
committed by
Pedro M. Baeza
15 changed files with 191 additions and 122 deletions
-
32partner_street_number/README.rst
-
24partner_street_number/__init__.py
-
22partner_street_number/__manifest__.py
-
25partner_street_number/hooks.py
-
2partner_street_number/i18n/es.po
-
2partner_street_number/i18n/nl.po
-
46partner_street_number/i18n/partner_street_number.pot
-
2partner_street_number/i18n/pt_BR.po
-
2partner_street_number/i18n/sl.po
-
33partner_street_number/models/res_partner.py
-
26partner_street_number/static/src/css/field.less
-
5partner_street_number/tests/__init__.py
-
23partner_street_number/tests/test_res_partner.py
-
10partner_street_number/views/assets.xml
-
59partner_street_number/views/res_partner.xml
@ -0,0 +1,25 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2013-2015 Therp BV (<http://therp.nl>) |
|||
# Copyright 2016 Onestein (<http://www.onestein.eu>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
import logging |
|||
from odoo import SUPERUSER_ID, api |
|||
|
|||
|
|||
def post_init_hook(cr, registry): |
|||
""" |
|||
Post-install script. Because 'street' is now a stored function field, we |
|||
should be able to retrieve its values from the cursor. We use those to |
|||
fill the new name/number fields using the street field's inverse function, |
|||
which does a basic street name/number split. |
|||
""" |
|||
logging.getLogger('odoo.addons.partner_street_number').info( |
|||
'Migrating existing street names') |
|||
|
|||
env = api.Environment(cr, SUPERUSER_ID, {}) |
|||
partners = env['res.partner'].with_context(active_test=False).search([ |
|||
('street', '!=', False), |
|||
('street_name', '=', False) |
|||
]) |
|||
partners._write_street() |
@ -1,46 +0,0 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * partner_street_number |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 8.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2015-03-12 22:26+0000\n" |
|||
"PO-Revision-Date: 2015-03-12 22:26+0000\n" |
|||
"Last-Translator: <>\n" |
|||
"Language-Team: \n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Plural-Forms: \n" |
|||
|
|||
#. module: partner_street_number |
|||
#: view:res.partner:partner_street_number.view_partner_form |
|||
msgid "Number..." |
|||
msgstr "" |
|||
|
|||
#. module: partner_street_number |
|||
#: model:ir.model,name:partner_street_number.model_res_partner |
|||
msgid "Partner" |
|||
msgstr "" |
|||
|
|||
#. module: partner_street_number |
|||
#: field:res.partner,street_name:0 |
|||
msgid "Street name" |
|||
msgstr "" |
|||
|
|||
#. module: partner_street_number |
|||
#: field:res.partner,street_number:0 |
|||
msgid "Street number" |
|||
msgstr "" |
|||
|
|||
#. module: partner_street_number |
|||
#: view:res.partner:partner_street_number.view_partner_form |
|||
msgid "Street..." |
|||
msgstr "" |
|||
|
|||
#. module: partner_street_number |
|||
#: view:res.partner:partner_street_number.view_partner_form |
|||
msgid "{'default_parent_id': active_id, 'default_street_name': street_name, 'default_street_number': street_number, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_supplier': supplier, 'default_customer': customer, 'default_use_parent_address': True}" |
|||
msgstr "" |
@ -0,0 +1,26 @@ |
|||
.o_form_view { |
|||
|
|||
&.o_form_editable .o_address_format { |
|||
input.o_address_street_name { |
|||
float: left; |
|||
margin-right: 2%; |
|||
width: 73%; |
|||
} |
|||
|
|||
input.o_address_street_number { |
|||
margin-right: 0%; |
|||
width: 25%; |
|||
} |
|||
} |
|||
|
|||
.o_address_format { |
|||
span.o_address_street_name { |
|||
float: left; |
|||
margin-right: 2%; |
|||
} |
|||
|
|||
span.o_address_street_number { |
|||
margin-right: 2%; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,5 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 ONESTEiN BV (<http://www.onestein.eu>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import test_res_partner |
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 ONESTEiN BV (<http://www.onestein.eu>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo.tests.common import TransactionCase |
|||
|
|||
|
|||
class TestResPartner(TransactionCase): |
|||
|
|||
def setUp(self): |
|||
super(TestResPartner, self).setUp() |
|||
self.main_partner = self.env.ref('base.main_partner') |
|||
|
|||
def test_display_address(self): |
|||
# method name_get() having show_address=True in context |
|||
# will invoke method _display_address() |
|||
partner_test = self.main_partner.with_context(show_address=True) |
|||
displayed_name = partner_test.name_get() |
|||
|
|||
self.assertEqual( |
|||
displayed_name[0][1], |
|||
'YourCompany\n1725 Slough Ave.\nScranton PA 18540\nUnited States' |
|||
) |
@ -0,0 +1,10 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<odoo> |
|||
|
|||
<template id="assets_backend" name="partner_street_number backend assets" inherit_id="web.assets_backend"> |
|||
<xpath expr="." position="inside"> |
|||
<link rel="stylesheet" href="/partner_street_number/static/src/css/field.less"/> |
|||
</xpath> |
|||
</template> |
|||
|
|||
</odoo> |
@ -1,52 +1,67 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<openerp> |
|||
<data> |
|||
<odoo> |
|||
|
|||
<record id="view_partner_form" model="ir.ui.view"> |
|||
<field name="name">Add separate fields for street name and number</field> |
|||
<field name="model">res.partner</field> |
|||
<field name="inherit_id" ref="base.view_partner_form"/> |
|||
<field name="arch" type="xml"> |
|||
|
|||
<xpath expr="/form/sheet//div/field[@name='street']" |
|||
<xpath expr="//div[@class='o_address_format']//field[@name='street']" |
|||
position="after"> |
|||
<div> |
|||
<field name="street_name" style="width: 80%%" |
|||
placeholder="Street..." |
|||
attrs="{'readonly': [('use_parent_address','=',True)]}" |
|||
<field name="street_name" class="o_address_street_name" |
|||
placeholder="Street..." |
|||
attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}" |
|||
/> |
|||
<field name="street_number" style="width: 19%%" |
|||
placeholder="Number..." |
|||
attrs="{'readonly': [('use_parent_address','=',True)]}" |
|||
<field name="street_number" class="o_address_street_number" |
|||
placeholder="Number..." |
|||
attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}" |
|||
/> |
|||
</div> |
|||
</xpath> |
|||
<xpath expr="/form/sheet//div/field[@name='street']" |
|||
<xpath expr="//div[@class='o_address_format']//field[@name='street']" |
|||
position="attributes"> |
|||
<attribute name="invisible">1</attribute> |
|||
</xpath> |
|||
|
|||
<xpath expr="//form[@string='Contact']/sheet/group/div/field[@name='street']" |
|||
<xpath expr="//div[@name='div_address']//field[@name='street']" |
|||
position="after"> |
|||
<div> |
|||
<field name="street_name" style="width: 80%%" |
|||
<field name="street_name" class="o_address_street_name" |
|||
placeholder="Street..." |
|||
/> |
|||
<field name="street_number" style="width: 19%%" |
|||
<field name="street_number" class="o_address_street_number" |
|||
placeholder="Number..." |
|||
/> |
|||
</div> |
|||
</xpath> |
|||
<xpath expr="//form[@string='Contact']/sheet/group/div/field[@name='street']" |
|||
<xpath expr="//div[@name='div_address']//field[@name='street']" |
|||
position="attributes"> |
|||
<attribute name="invisible">1</attribute> |
|||
</xpath> |
|||
|
|||
<xpath expr="//field[@name='child_ids']" position="attributes"> |
|||
<attribute name="context">{'default_parent_id': active_id, 'default_street_name': street_name, 'default_street_number': street_number, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_supplier': supplier, 'default_customer': customer, 'default_use_parent_address': True}</attribute> |
|||
<attribute name="context">{'default_parent_id': active_id, 'default_street_name': street_name, 'default_street_number': street_number, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_supplier': supplier, 'default_customer': customer}</attribute> |
|||
</xpath> |
|||
|
|||
</field> |
|||
</record> |
|||
</data> |
|||
</openerp> |
|||
|
|||
<record id="view_partner_address_form" model="ir.ui.view"> |
|||
<field name="name">Add separate fields for street name and number in address form</field> |
|||
<field name="model">res.partner</field> |
|||
<field name="inherit_id" ref="base.view_partner_address_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//div[@class='o_address_format']//field[@name='street']" |
|||
position="after"> |
|||
<field name="street_name" class="o_address_street_name" |
|||
placeholder="Street..." |
|||
/> |
|||
<field name="street_number" class="o_address_street_number" |
|||
placeholder="Number..." |
|||
/> |
|||
</xpath> |
|||
<xpath expr="//div[@class='o_address_format']//field[@name='street']" |
|||
position="attributes"> |
|||
<attribute name="invisible">1</attribute> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue