[IMP] website: res_config with wizard
authorChristophe Matthieu <chm@openerp.com>
Mon, 27 Jan 2014 17:38:16 +0000 (18:38 +0100)
committerChristophe Matthieu <chm@openerp.com>
Mon, 27 Jan 2014 17:38:16 +0000 (18:38 +0100)
bzr revid: chm@openerp.com-20140127173816-uldoee71h7ntpyhl

addons/website/__openerp__.py
addons/website/models/__init__.py
addons/website/models/res_config.py [new file with mode: 0644]
addons/website/static/src/js/website.editor.js
addons/website/views/res_config.xml [new file with mode: 0644]
addons/website/views/website_views.xml
addons/website_sale/models/website.py

index c7969da..9161255 100644 (file)
@@ -19,6 +19,7 @@ OpenERP Website CMS
         'views/website_views.xml',
         'views/snippets.xml',
         'views/themes.xml',
+        'views/res_config.xml',
     ],
     'demo': [
         'data/website_demo.xml',
index 7b1fb06..e17fba6 100644 (file)
@@ -4,5 +4,6 @@ import ir_ui_view
 import website
 import ir_qweb
 import ir_http
+import res_config
 
 import test_models
diff --git a/addons/website/models/res_config.py b/addons/website/models/res_config.py
new file mode 100644 (file)
index 0000000..f2c56a9
--- /dev/null
@@ -0,0 +1,39 @@
+
+from openerp.osv import fields, osv
+
+class website_config_settings(osv.osv_memory):
+    _name = 'website.config.settings'
+    _inherit = 'base.config.settings'
+
+    _columns = {
+        'website_id': fields.many2one('website', string="website", required=True),
+
+        'language_ids': fields.related('website_id', 'language_ids', type='many2many', relation='res.lang', string='Languages'),
+        'default_lang_id': fields.related('website_id', 'default_lang_id', type='many2one', relation='res.lang', string='Default language'),
+        'default_lang_code': fields.related('website_id', 'default_lang_code', type="char", string="Default language code"),
+        'google_analytics_key': fields.related('website_id', 'google_analytics_key', type="char", string='Google Analytics Key'),
+        
+        'social_twitter': fields.related('website_id', 'social_twitter', type="char", string='Twitter Account'),
+        'social_facebook': fields.related('website_id', 'social_facebook', type="char", string='Facebook Account'),
+        'social_github': fields.related('website_id', 'social_github', type="char", string='GitHub Account'),
+        'social_linkedin': fields.related('website_id', 'social_linkedin', type="char", string='LinkedIn Account'),
+        'social_youtube': fields.related('website_id', 'social_youtube', type="char", string='Youtube Account'),
+        'social_googleplus': fields.related('website_id', 'social_googleplus', type="char", string='Google+ Account'),
+
+        'module_website_sale': fields.boolean('E-Commerce', help='Sell Your Products Online'),
+        'module_website_blog': fields.boolean('Blog', help='News, Blogs, Announces, Discussions'),
+        'module_website_event': fields.boolean('Event', help='Schedule, Promote and Sell Events'),
+        'module_website_hr_recruitment': fields.boolean('Job Position', help='Promote Your Job Positions'),
+    }
+
+    def on_change_website_id(self, cr, uid, ids, id, context=None):
+        website_data = self.pool.get('website').read(cr, uid, [id], [], context=context)[0]
+        values = {}
+        for fname, v in website_data.items():
+            if self._columns.get(fname):
+                values[fname] = v and self._columns[fname]._type == 'many2one' and v[0] or v
+        return {'value' : values}
+
+    _defaults = {
+        'website_id': lambda self,cr,uid,c: self.pool.get('website').search(cr, uid, [], context=c)[0],
+    }
index fcc7dbb..948e584 100644 (file)
                         menu.append('<li><a data-action="ace" href="#">HTML Editor</a></li>');
                         menu.append('<li class="js_change_theme"><a href="/page/website.themes">Change Theme</a></li>');
                         menu.append('<li><a href="/web#return_label=Website&action=website.action_module_website">Install Apps</a></li>');
-                        menu.append('<li><a href="/web#return_label=Website&action=website.action_website_form">Website Settings</a></li>');
+                        menu.append('<li><a href="/web#return_label=Website&action=website.action_website_configuration">Website Settings</a></li>');
                         self.trigger('rte:customize_menu_ready');
                     }
                 );
diff --git a/addons/website/views/res_config.xml b/addons/website/views/res_config.xml
new file mode 100644 (file)
index 0000000..e0d55ab
--- /dev/null
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <record id="view_website_config_settings" model="ir.ui.view">
+            <field name="name">Website settings</field>
+            <field name="model">website.config.settings</field>
+            <field name="arch" type="xml">
+                <form string="Configure Website" version="7.0" class="oe_form_configuration">
+                    <header>
+                        <button string="Apply" type="object" name="execute" class="oe_highlight"/>
+                        or
+                        <button string="Cancel" type="object" name="cancel" class="oe_link"/>
+                    </header>
+                    <div>
+                        <field name="website_id" invisible="True" on_change="on_change_website_id(website_id)"/>
+                        <group string="Domain">
+                            <label for="google_analytics_key"/>
+                            <div name="google_analytics_key">
+                                <div>
+                                    <div name="google_analytics_key" class="oe_inline">
+                                        <field name="google_analytics_key" placeholder="UA-XXXXXXXX-Y"/>
+                                    </div>
+                                </div>
+                            </div>
+                        </group>
+                        <group string="Social Media">
+                            <label for="social_twitter"/>
+                            <div name="social_twitter">
+                                <div class="oe_inline">
+                                    <field name="social_twitter" placeholder="https://twitter.com/openerp"/>
+                                </div>
+                            </div>
+                            <label for="social_facebook"/>
+                            <div name="social_facebook">
+                                <div class="oe_inline">
+                                    <field name="social_facebook" placeholder="https://facebook.com/openerp"/>
+                                </div>
+                            </div>
+                            <label for="social_github"/>
+                            <div name="social_github">
+                                <div class="oe_inline">
+                                    <field name="social_github" placeholder="https://youraccount.github.io"/>
+                                </div>
+                            </div>
+                            <label for="social_linkedin"/>
+                            <div name="social_linkedin">
+                                <div class="oe_inline">
+                                    <field name="social_linkedin" placeholder="http://www.linkedin.com/company/openerp"/>
+                                </div>
+                            </div>
+                            <label for="social_youtube"/>
+                            <div name="social_youtube">
+                                <div class="oe_inline">
+                                    <field name="social_youtube" placeholder="http://www.youtube.com/channel/HCU842OHPPNrQ"/>
+                                </div>
+                            </div>
+                            <label for="social_googleplus"/>
+                            <div name="social_googleplus">
+                                <div class="oe_inline">
+                                    <field name="social_googleplus" placeholder="https://plus.google.com/+openerp"/>
+                                </div>
+                            </div>
+                        </group>
+                        <group string="Language">
+                            <label for="language_ids"/>
+                            <div name="language_ids">
+                                <div>
+                                    <div name="language_ids" class="oe_inline">
+                                        <field name="language_ids" widget="many2many_checkboxes"/>
+                                    </div>
+                                </div>
+                            </div>
+                            <label for="default_lang_id"/>
+                            <div name="default_lang_id">
+                                <div>
+                                    <div name="default_lang_id" class="oe_inline">
+                                        <field name="default_lang_id" widget="selection"/>
+                                    </div>
+                                </div>
+                            </div>
+                        </group>
+                        <group string="Your Apps">
+                            <label for="module_website_sale"/>
+                            <div name="module_website_sale">
+                                <div>
+                                    <div name="module_website_sale" class="oe_inline">
+                                        <field name="module_website_sale"/>
+                                    </div>
+                                </div>
+                            </div>
+                            <label for="module_website_event"/>
+                            <div name="module_website_event">
+                                <div>
+                                    <div name="module_website_event" class="oe_inline">
+                                        <field name="module_website_event"/>
+                                    </div>
+                                </div>
+                            </div>
+                            <label for="module_website_blog"/>
+                            <div name="module_website_blog">
+                                <div>
+                                    <div name="module_website_blog" class="oe_inline">
+                                        <field name="module_website_blog"/>
+                                    </div>
+                                </div>
+                            </div>
+                            <label for="module_website_hr_recruitment"/>
+                            <div name="module_website_hr_recruitment">
+                                <div>
+                                    <div name="module_website_hr_recruitment" class="oe_inline">
+                                        <field name="module_website_hr_recruitment"/>
+                                    </div>
+                                </div>
+                            </div>
+                            <button type="action"
+                                    name="%(website.action_module_website)d"
+                                    string="All Your Website Apps" class="oe_link"/>
+                        </group>
+                    </div>
+                </form>
+            </field>
+        </record>
+
+        <record id="action_website_configuration" model="ir.actions.act_window">
+            <field name="name">Website Settings</field>
+            <field name="res_model">website.config.settings</field>
+            <field name="view_mode">form</field>
+            <field name="target">inline</field>
+        </record>
+
+        <menuitem id="menu_website_configuration" parent="base.menu_config"
+            sequence="90" action="action_website_configuration"/>
+
+    </data>
+</openerp>
index d4cef6d..cf7be25 100644 (file)
             </field>
         </record>
 
-        <record id="action_website_form" model="ir.actions.act_window">
-            <field name="name">Website Settings</field>
-            <field name="type">ir.actions.act_window</field>
-            <field name="res_model">website</field>
-            <field name="res_id">1</field>
-            <field name="view_mode">form</field>
-            <field name="help">Create and manage the companies websites.</field>
-            <field name="target">inline</field>
-        </record>
-        <menuitem action="action_website_form" id="menu_action_website_form" parent="base.menu_config"/>
-
         <record id="view_base_language_install" model="ir.ui.view">
             <field name="name">view_base_language_install.inherit</field>
             <field name="model">base.language.install</field>
index 8ea4e01..1851e6e 100644 (file)
@@ -11,9 +11,7 @@ class Website(orm.Model):
     def _get_pricelist(self, cr, uid, ids, field_name, arg, context=None):
         # FIXME: oh god kill me now
         pricelist_id = self.ecommerce_get_pricelist_id(cr, uid, ids, context=context)
-        return dict.fromkeys(
-            ids, self.pool['product.pricelist'].browse(
-                cr, SUPERUSER_ID, pricelist_id, context=context))
+        return dict.fromkeys(ids, pricelist_id)
 
     _columns = {
         'pricelist_id': fields.function(