← Back to team overview

savoirfairelinux-openerp team mailing list archive

lp:~savoirfairelinux-openerp/partner-contact-management/city-move into lp:partner-contact-management

 

Sandy Carter (http://www.savoirfairelinux.com) has proposed merging lp:~savoirfairelinux-openerp/partner-contact-management/city-move into lp:partner-contact-management.

Requested reviews:
  Pedro Manuel Baeza (pedro.baeza)
  Nhomar - Vauxoo (nhomar)
  Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903): code review

For more details, see:
https://code.launchpad.net/~savoirfairelinux-openerp/partner-contact-management/city-move/+merge/196023

Move city module from lp:openerp-mexico-localization
-- 
https://code.launchpad.net/~savoirfairelinux-openerp/partner-contact-management/city-move/+merge/196023
Your team Savoir-faire Linux' OpenERP is subscribed to branch lp:~savoirfairelinux-openerp/partner-contact-management/city-move.
=== added directory 'city'
=== added file 'city/__init__.py'
--- city/__init__.py	1970-01-01 00:00:00 +0000
+++ city/__init__.py	2013-11-21 14:11:19 +0000
@@ -0,0 +1,30 @@
+# -*- encoding: utf-8 -*-
+###########################################################################
+#    Module Writen to OpenERP, Open Source Management Solution
+#
+#    Copyright (c) 2013 Vauxoo - http://www.vauxoo.com/
+#    All Rights Reserved.
+#    info Vauxoo (info@xxxxxxxxxx)
+############################################################################
+#    Coded by: moylop260 (moylop260@xxxxxxxxxx)
+#              Julio Serna (julio@xxxxxxxxxx)
+#              Isaac Lopez (isaac@xxxxxxxxxx)
+############################################################################
+#
+#    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 res_city
+import partner_address

=== added file 'city/__openerp__.py'
--- city/__openerp__.py	1970-01-01 00:00:00 +0000
+++ city/__openerp__.py	2013-11-21 14:11:19 +0000
@@ -0,0 +1,52 @@
+# -*- encoding: utf-8 -*-
+###########################################################################
+#    Module Writen to OpenERP, Open Source Management Solution
+#
+#    Copyright (c) 2013 Vauxoo - http://www.vauxoo.com/
+#    All Rights Reserved.
+#    info Vauxoo (info@xxxxxxxxxx)
+############################################################################
+#    Coded by: moylop260 (moylop260@xxxxxxxxxx)
+#              Julio Serna (julio@xxxxxxxxxx)
+#              Isaac Lopez (isaac@xxxxxxxxxx)
+############################################################################
+#
+#    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/>.
+#
+##############################################################################
+
+{
+    "name": "City",
+    "version": "1.0",
+    "author": "Vauxoo",
+    "category": "Localization",
+    "description": """
+This module creates the city model similar to states model and adds the field city_id on res partner.
+    """,
+    "website": "http://www.vauxoo.com/";,
+    "license": "AGPL-3",
+    "depends": [
+        "base",
+    ],
+    "init_xml": [],
+    "demo_xml": [],
+    "update_xml": [
+        'res_city_view.xml',
+        'partner_address_view.xml',
+        'security/city_security.xml',
+        'security/ir.model.access.csv',
+    ],
+    "installable": True,
+    "active": False,
+}

=== added directory 'city/i18n'
=== added file 'city/i18n/es.po'
--- city/i18n/es.po	1970-01-01 00:00:00 +0000
+++ city/i18n/es.po	2013-11-21 14:11:19 +0000
@@ -0,0 +1,70 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* city
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-02-22 16:20+0000\n"
+"PO-Revision-Date: 2013-02-22 10:21-0600\n"
+"Last-Translator: Isaac Lopez <isaac@xxxxxxxxxx>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"
+
+#. module: city
+#: view:res.country.state.city:0
+#: field:res.partner,city_id:0
+msgid "City"
+msgstr "Ciudad"
+
+#. module: city
+#: help:res.country.state.city,name:0
+msgid "Administrative divisions of a state."
+msgstr "División administrativa de un estado"
+
+#. module: city
+#: field:res.country.state.city,name:0
+msgid "Name"
+msgstr "Nombre"
+
+#. module: city
+#: model:ir.model,name:city.model_res_country_state_city
+msgid "Country state city"
+msgstr "Pais-estado-ciudad"
+
+#. module: city
+#: field:res.country.state.city,country_id:0
+msgid "Country"
+msgstr "Pais"
+
+#. module: city
+#: field:res.country.state.city,code:0
+msgid "City Code"
+msgstr "Código de Ciudad"
+
+#. module: city
+#: view:res.country.state.city:0
+#: field:res.country.state.city,state_id:0
+msgid "State"
+msgstr "Estado"
+
+#. module: city
+#: help:res.country.state.city,code:0
+msgid "The city code in max. five chars."
+msgstr "Código de la ciudad, máximo 5 caracteres"
+
+#. module: city
+#: model:ir.model,name:city.model_res_partner
+msgid "Partner"
+msgstr "Empresa"
+
+#. module: city
+#: model:ir.actions.act_window,name:city.action_country_state_city
+#: model:ir.ui.menu,name:city.menu_country_state_city_partner
+msgid "Cities"
+msgstr "Ciudades"
+

=== added file 'city/i18n/es_MX.po'
--- city/i18n/es_MX.po	1970-01-01 00:00:00 +0000
+++ city/i18n/es_MX.po	2013-11-21 14:11:19 +0000
@@ -0,0 +1,16 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* city
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-02-22 16:20+0000\n"
+"PO-Revision-Date: 2013-02-22 10:21-0600\n"
+"Last-Translator: Isaac Lopez <isaac@xxxxxxxxxx>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"

=== added file 'city/i18n/es_VE.po'
--- city/i18n/es_VE.po	1970-01-01 00:00:00 +0000
+++ city/i18n/es_VE.po	2013-11-21 14:11:19 +0000
@@ -0,0 +1,16 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* city
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-02-22 16:20+0000\n"
+"PO-Revision-Date: 2013-02-22 10:21-0600\n"
+"Last-Translator: Isaac Lopez <isaac@xxxxxxxxxx>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"

=== added file 'city/partner_address.py'
--- city/partner_address.py	1970-01-01 00:00:00 +0000
+++ city/partner_address.py	2013-11-21 14:11:19 +0000
@@ -0,0 +1,75 @@
+# -*- encoding: utf-8 -*-
+###########################################################################
+#    Module Writen to OpenERP, Open Source Management Solution
+#
+#    Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
+#    All Rights Reserved.
+#    info Vauxoo (info@xxxxxxxxxx)
+############################################################################
+#    Coded by: moylop260 (moylop260@xxxxxxxxxx)
+#              Julio Serna (julio@xxxxxxxxxx)
+#              Isaac Lopez (isaac@xxxxxxxxxx)
+############################################################################
+#
+#    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 openerp.osv import orm, fields
+
+
+class res_partner(orm.BaseModel):
+    _inherit = 'res.partner'
+
+    _columns = {
+        'city_id': fields.many2one('res.country.state.city', 'City'),
+    }
+
+    def fields_view_get(self, cr, user, view_id=None, view_type='form',
+                        context=None, toolbar=False, submenu=False):
+        if (not view_id and view_type == 'form' and context
+                and context.get('force_email', False)):
+            view_id = self.pool.get('ir.model.data').get_object_reference(
+                cr, user, 'base', 'res_partner_form_city_01')[1]
+        res = super(res_partner, self).fields_view_get(
+            cr, user, view_id, view_type, context, toolbar=toolbar,
+            submenu=submenu)
+        if view_type == 'form':
+            res['arch'] = self.fields_view_get_address(
+                cr, user, res['arch'], context=context)
+        return res
+
+    def onchange_city(self, cr, uid, ids, city_id, context=None):
+        if city_id:
+            city = self.pool.get('res.country.state.city').browse(
+                cr, uid, city_id, context)
+            return {'value': {
+                'city': city.name,
+                'state_id': city.state_id.id,
+                'country_id': city.country_id and city.country_id.id or False
+            }}
+        return {}
+
+    def onchange_state_city(self, cr, uid, ids, state_id, city_id,
+                            context=None):
+        res = super(res_partner, self).onchange_state(cr, uid, ids,
+                                                      state_id, context)
+        city = self.pool.get('res.country.state.city')
+        if city_id:
+            pool_state_id = city.browse(cr, uid, city_id, context)
+            if pool_state_id != state_id and res and 'value' in res:
+                res['value']['city'] = None
+                res['value']['city_id'] = None
+        return res
+

=== added file 'city/partner_address_view.xml'
--- city/partner_address_view.xml	1970-01-01 00:00:00 +0000
+++ city/partner_address_view.xml	2013-11-21 14:11:19 +0000
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record  model="ir.ui.view" id="res_partner_form_city_01">
+            <field name="name">res.partner.form_city_01</field>
+            <field name="model">res.partner</field>
+            <field name="inherit_id" ref="base.view_partner_form"/>
+            <field name="arch" type="xml">
+                
+                <xpath expr="//field[@name='country_id']" position="after">
+                    <field name="city_id" on_change="onchange_city(city_id)"  placeholder="Ciudad"/>
+                </xpath>
+                <xpath expr="//field[@name='state_id']" position="replace">
+                    <field name="state_id" class="oe_no_button" placeholder="State" style="width: 37%%" options='{"no_open": True}' on_change="onchange_state_city(state_id,city_id)" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
+                </xpath>
+            </field>
+        </record>
+
+    </data>
+</openerp>
+

=== added file 'city/res_city.py'
--- city/res_city.py	1970-01-01 00:00:00 +0000
+++ city/res_city.py	2013-11-21 14:11:19 +0000
@@ -0,0 +1,52 @@
+# -*- encoding: utf-8 -*-
+###########################################################################
+#    Module Writen to OpenERP, Open Source Management Solution
+#
+#    Copyright (c) 2013 Vauxoo - http://www.vauxoo.com/
+#    All Rights Reserved.
+#    info Vauxoo (info@xxxxxxxxxx)
+############################################################################
+#    Coded by: moylop260 (moylop260@xxxxxxxxxx)
+#              Isaac Lopez (isaac@xxxxxxxxxx)
+############################################################################
+#
+#    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 openerp.osv import osv, fields
+from openerp import tools
+from openerp.tools.translate import _
+
+import math
+import re
+import logging
+from lxml import etree
+
+
+class res_country_state_city(osv.Model):
+    _description = "Country state city"
+    _name = 'res.country.state.city'
+    _columns = {
+        'name': fields.char('Name', size=64, required=True, select=True,
+                help='Administrative divisions of a state.'),
+        'state_id': fields.many2one('res.country.state', 'State',
+                    required=True),
+        'country_id': fields.related('state_id', 'country_id',
+                    type='many2one', relation='res.country',
+                    string='Country', store=True, readonly=True),
+        'code': fields.char('City Code', size=5,
+                            help='The city code in max. five chars.'),
+    }
+    _order = 'name'

=== added file 'city/res_city_view.xml'
--- city/res_city_view.xml	1970-01-01 00:00:00 +0000
+++ city/res_city_view.xml	2013-11-21 14:11:19 +0000
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!--
+          City
+        -->
+
+        <record id="view_country_state_city_tree" model="ir.ui.view">
+            <field name="name">res.country.state.city.tree</field>
+            <field name="model">res.country.state.city</field>
+            <field name="arch" type="xml">
+                <tree string="City">
+                    <field name="name"/>
+                    <field name="code"/>
+                    <field name="state_id"/>
+                    <field name="country_id"/>
+                </tree>
+            </field>
+        </record>
+
+        <record id="view_country_state_city_form" model="ir.ui.view">
+            <field name="name">res.country.state.city.form</field>
+            <field name="model">res.country.state.city</field>
+            <field name="arch" type="xml">
+                <form string="State" version="7.0">
+                    <group>
+                        <field name="name"/>
+                        <field name="code"/>
+                        <field name="state_id" options='{"no_open": True}'/>
+                        <field name="country_id" options='{"no_open": True}'/>
+                    </group>
+                </form>
+            </field>
+        </record>
+
+        <record id="action_country_state_city" model="ir.actions.act_window">
+            <field name="name">Cities</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">res.country.state.city</field>
+            <field name="view_type">form</field>
+            <field name="view_id" ref="view_country_state_city_tree"/>
+        </record>
+
+          <menuitem action="action_country_state_city" id="menu_country_state_city_partner" parent="base.menu_localisation" sequence="1" groups="base.group_no_one"/>
+    </data>
+</openerp>

=== added directory 'city/security'
=== added file 'city/security/city_security.xml'
--- city/security/city_security.xml	1970-01-01 00:00:00 +0000
+++ city/security/city_security.xml	2013-11-21 14:11:19 +0000
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        
+        <record model="res.groups" id="group_res_country_state_city_manager">
+            <field name="name">City Manager</field>
+        </record>
+        
+    </data>
+</openerp>

=== added file 'city/security/ir.model.access.csv'
--- city/security/ir.model.access.csv	1970-01-01 00:00:00 +0000
+++ city/security/ir.model.access.csv	2013-11-21 14:11:19 +0000
@@ -0,0 +1,3 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_res_country_state_city_manager,res_country_state_city_manager,model_res_country_state_city,group_res_country_state_city_manager,1,1,1,1
+access_res_country_state_city_user,res_country_state_city_user,model_res_country_state_city,,1,0,0,0


Follow ups