[PARTNER] +country_id and nationality_id default value is 'France'
authorLudovic CHEVALIER <ludovic.chevalier@heureux-cyclage.org>
Wed, 15 Jan 2014 17:31:41 +0000 (18:31 +0100)
committerLudovic CHEVALIER <ludovic.chevalier@heureux-cyclage.org>
Wed, 15 Jan 2014 17:31:41 +0000 (18:31 +0100)
__init__.py
bikecoop.py [new file with mode: 0644]

index 7d48af2..c48dfbc 100644 (file)
@@ -21,5 +21,6 @@
 #
 ##############################################################################
 
+import bikecoop
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/bikecoop.py b/bikecoop.py
new file mode 100644 (file)
index 0000000..7fe5b64
--- /dev/null
@@ -0,0 +1,27 @@
+from openerp.osv import osv
+from openerp.osv import fields
+
+class Partner(osv.osv):
+    _inherit = 'res.partner'
+
+    def _default_country(self, cr, uid, context=None):
+        if not context:
+            context = {}
+        country_obj = self.pool.get('res.country')
+        country = country_obj.search(cr, uid, [('name', '=', 'France')], context=context)
+        return country
+
+    def _default_nationality(self, cr, uid, context=None):
+        if not context:
+            context = {}
+        nationality_obj = self.pool.get('res.country')
+        nationality = nationality_obj.search(cr, uid, [('name', '=', 'France')], context=context)
+        return nationality
+
+    _defaults = {
+        'country_id': _default_country,
+        'nationality_id': _default_nationality,
+    }
+
+Partner()
+