Stefan Rijnhart
10 years ago
10 changed files with 173 additions and 166 deletions
-
48partner_street_number/README.rst
-
44partner_street_number/__init__.py
-
28partner_street_number/__openerp__.py
-
39partner_street_number/i18n/nl.po
-
43partner_street_number/i18n/partner_street_number.pot
-
46partner_street_number/migrations/0.1/post-migrate.py
-
0partner_street_number/models/__init__.py
-
87partner_street_number/models/res_partner.py
-
BINpartner_street_number/static/description/icon.png
-
4partner_street_number/views/res_partner.xml
@ -0,0 +1,48 @@ |
|||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
||||
|
:alt: License |
||||
|
|
||||
|
Split street name and number |
||||
|
============================ |
||||
|
|
||||
|
This module introduces separate fields for street name and street number. |
||||
|
|
||||
|
Changes to the Odoo datamodel |
||||
|
============================= |
||||
|
- Introduce two new fields for street name and number |
||||
|
- Keep 'Street' field as a function field to return street name + number |
||||
|
- Data written to the 'Street' field will be parsed into street name and number |
||||
|
if possible. This will be performed upon installation of the module for |
||||
|
existing partners. |
||||
|
|
||||
|
Compatibility |
||||
|
============= |
||||
|
This module is compatible with OpenERP 8.0. |
||||
|
|
||||
|
|
||||
|
Installation |
||||
|
============ |
||||
|
|
||||
|
Upon installation, the module will do a simple migration of existing values in |
||||
|
the street column to split up the street name and number. |
||||
|
|
||||
|
Credits |
||||
|
======= |
||||
|
|
||||
|
Contributors |
||||
|
------------ |
||||
|
|
||||
|
* Stefan Rijnhart <stefan@therp.nl> |
||||
|
* Ronald Portier <ronald@therp.nl> |
||||
|
|
||||
|
Maintainer |
||||
|
---------- |
||||
|
|
||||
|
.. image:: http://odoo-community.org/logo.png |
||||
|
:alt: Odoo Community Association |
||||
|
:target: http://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. |
@ -1 +1,43 @@ |
|||||
from . import model |
|
||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Odoo, an open source suite of business apps |
||||
|
# This module copyright (C) 2013-2015 Therp BV (<http://therp.nl>). |
||||
|
# |
||||
|
# This program is free software: you can redistribute it and/or modify |
||||
|
# it under the terms of the GNU Affero General Public License as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU Affero General Public License for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU Affero General Public License |
||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from . import models |
||||
|
|
||||
|
import logging |
||||
|
from openerp import SUPERUSER_ID |
||||
|
|
||||
|
|
||||
|
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('openerp.addons.partner_street_number').info( |
||||
|
'Migrating existing street names') |
||||
|
cr.execute( |
||||
|
'SELECT id, street FROM res_partner ' |
||||
|
'WHERE street IS NOT NULL and street_name IS NULL' |
||||
|
) |
||||
|
partner_obj = registry['res.partner'] |
||||
|
for partner in cr.fetchall(): |
||||
|
partner_obj.write( |
||||
|
cr, SUPERUSER_ID, partner[0], {'street': partner[1]}) |
@ -1,41 +1,46 @@ |
|||||
# Translation of OpenERP Server. |
|
||||
|
# Translation of Odoo Server. |
||||
# This file contains the translation of the following modules: |
# This file contains the translation of the following modules: |
||||
# * partner_street_number |
|
||||
|
# * partner_street_number |
||||
# |
# |
||||
msgid "" |
msgid "" |
||||
msgstr "" |
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 |
#. module: partner_street_number |
||||
#: field:res.partner,street_name:0 |
|
||||
msgid "Street name" |
|
||||
|
#: view:res.partner:partner_street_number.view_partner_form |
||||
|
msgid "Number..." |
||||
msgstr "" |
msgstr "" |
||||
|
|
||||
#. module: partner_street_number |
#. module: partner_street_number |
||||
#: field:res.partner,street_number:0 |
|
||||
msgid "Street number" |
|
||||
|
#: model:ir.model,name:partner_street_number.model_res_partner |
||||
|
msgid "Partner" |
||||
msgstr "" |
msgstr "" |
||||
|
|
||||
#. module: partner_street_number |
#. module: partner_street_number |
||||
#: view:res.partner:0 |
|
||||
msgid "Number..." |
|
||||
|
#: field:res.partner,street_name:0 |
||||
|
msgid "Street name" |
||||
msgstr "" |
msgstr "" |
||||
|
|
||||
#. module: partner_street_number |
#. module: partner_street_number |
||||
#: view:res.partner:0 |
|
||||
msgid "Street..." |
|
||||
|
#: field:res.partner,street_number:0 |
||||
|
msgid "Street number" |
||||
msgstr "" |
msgstr "" |
||||
|
|
||||
#. module: partner_street_number |
#. module: partner_street_number |
||||
#: view:res.partner:0 |
|
||||
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}" |
|
||||
|
#: view:res.partner:partner_street_number.view_partner_form |
||||
|
msgid "Street..." |
||||
msgstr "" |
msgstr "" |
||||
|
|
||||
#. module: partner_street_number |
#. module: partner_street_number |
||||
#: model:ir.model,name:partner_street_number.model_res_partner |
|
||||
msgid "Partner" |
|
||||
|
#: 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 "" |
msgstr "" |
@ -1,46 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
############################################################################## |
|
||||
# |
|
||||
# OpenERP, Open Source Management Solution |
|
||||
# This module copyright (C) 2013-2014 Therp BV (<http://therp.nl>). |
|
||||
# |
|
||||
# @autors: Stefan Rijnhart, Ronald Portier |
|
||||
# |
|
||||
# This program is free software: you can redistribute it and/or modify |
|
||||
# it under the terms of the GNU Affero General Public License as |
|
||||
# published by the Free Software Foundation, either version 3 of the |
|
||||
# License, or (at your option) any later version. |
|
||||
# |
|
||||
# This program is distributed in the hope that it will be useful, |
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
# GNU Affero General Public License for more details. |
|
||||
# |
|
||||
# You should have received a copy of the GNU Affero General Public License |
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
############################################################################## |
|
||||
import logging |
|
||||
from openerp import pooler, SUPERUSER_ID |
|
||||
|
|
||||
|
|
||||
def migrate(cr, version): |
|
||||
""" |
|
||||
Post-install script. If version is not set, we are called at installation |
|
||||
time. 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. |
|
||||
""" |
|
||||
if version: |
|
||||
return |
|
||||
logging.getLogger('openerp.addons.partner_street_number').info( |
|
||||
'Migrating existing street names') |
|
||||
cr.execute( |
|
||||
'SELECT id, street FROM res_partner ' |
|
||||
'WHERE street IS NOT NULL and street_name IS NULL' |
|
||||
) |
|
||||
partner_obj = pooler.get_pool(cr.dbname)['res.partner'] |
|
||||
for partner in cr.fetchall(): |
|
||||
partner_obj.write( |
|
||||
cr, SUPERUSER_ID, partner[0], {'street': partner[1]}) |
|
After Width: 180 | Height: 180 | Size: 12 KiB |
Write
Preview
Loading…
Cancel
Save
Reference in new issue