Skip to content

Commit

Permalink
[MERGE] trunk-website-al
Browse files Browse the repository at this point in the history
  • Loading branch information
antonylesuisse committed Jan 31, 2014
2 parents ba2d4c9 + 1c283dd commit 4b30f1f
Show file tree
Hide file tree
Showing 1,036 changed files with 52,609 additions and 40,449 deletions.
2 changes: 1 addition & 1 deletion addons/account/account_unit_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<field name="partner_id" ref="base.res_partner_1"/>
<field name="journal_id" ref="account.sales_journal"/>
<field name="state">draft</field>
<field name="type">out_invoice</field>
<field name="type">in_invoice</field>
<field name="account_id" ref="account.a_recv"/>
<field name="name">Test invoice 1</field>
</record>
Expand Down
1 change: 1 addition & 0 deletions addons/account/account_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,7 @@
<record id="view_move_line_tree_reconcile" model="ir.ui.view">
<field name="model">account.move.line</field>
<field eval="24" name="priority"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree_account_reconciliation colors="red:state == 'draft';black:state == 'valid'" string="Journal Items to Reconcile" create="false" version="7.0">
<field name="date"/>
Expand Down
28 changes: 18 additions & 10 deletions addons/account/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
<page string="Accounting" groups="account.group_account_invoice">
<group name="properties">
<group>
<field name="property_account_income" domain="[('type','=','other')]" groups="account.group_account_user"/>
<field name="taxes_id" colspan="2" attrs="{'readonly':[('sale_ok','=',0)]}" widget="many2many_tags"/>
<field name="property_account_income" domain="[('type','=','other')]" groups="account.group_account_user"
attrs="{'readonly': [('is_only_child', '=', False)]}"/>
<field name="taxes_id" colspan="2" widget="many2many_tags"
attrs="{'readonly':[ '|', ('sale_ok','=',0), ('is_only_child', '=', False)]}"/>
</group>
<group>
<field name="property_account_expense" domain="[('type','=','other')]" groups="account.group_account_user"/>
<field name="supplier_taxes_id" colspan="2" widget="many2many_tags"/>
<field name="property_account_expense" domain="[('type','=','other')]" groups="account.group_account_user"
attrs="{'readonly': [('is_only_child', '=', False)]}"/>
<field name="supplier_taxes_id" colspan="2" widget="many2many_tags"
attrs="{'readonly': [('is_only_child', '=', False)]}"/>
</group>
</group>
</page>
Expand All @@ -31,12 +35,16 @@
<field name="arch" type="xml">
<notebook position="inside">
<page string="Accounting">
<separator string="Sales Properties" colspan="2"/>
<separator string="Purchase Properties" colspan="2"/>
<field name="property_account_income" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="property_account_expense" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="taxes_id"/>
<field name="supplier_taxes_id"/>
<group name="properties">
<group>
<field name="property_account_income" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="taxes_id" colspan="2" widget="many2many_tags"/>
</group>
<group>
<field name="property_account_expense" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="supplier_taxes_id" colspan="2" widget="many2many_tags"/>
</group>
</group>
</page>
</notebook>
</field>
Expand Down
4 changes: 2 additions & 2 deletions addons/account/res_config_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,14 @@
<group name="bank_cash">
<label for="id" string="Configuration"/>
<div>
<div>
<div name='company_footer'>
<label for="company_footer"/>
<button name="open_company_form" type="object"
string="Configure your company bank accounts" icon="gtk-go-forward"
class="oe_inline oe_link"/>
<field name="company_footer"/>
</div>
<div>
<div name='payment_acquirer'>
<label for="paypal_account"/>
<field name="paypal_account" placeholder="e.g. [email protected]" class="oe_inline"/>
</div>
Expand Down
8 changes: 4 additions & 4 deletions addons/account_anglo_saxon/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<field name="model">product.product</field>
<field name="inherit_id" ref="account.product_normal_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='property_account_expense']" position="after">
<field name="property_account_expense" position="after">
<label string="" colspan="2"/>
<field name="property_account_creditor_price_difference" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />
<newline/>
</xpath>
</field>
</field>
</record>

Expand All @@ -19,10 +19,10 @@
<field name="model">product.template</field>
<field name="inherit_id" ref="account.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page/field[@name='property_account_expense']" position="after">
<field name="property_account_expense" position="after">
<field name="property_account_creditor_price_difference" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />
<newline/>
</xpath>
</field>
</field>
</record>

Expand Down
10 changes: 3 additions & 7 deletions addons/auth_oauth/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@
'website': 'http://www.openerp.com',
'depends': ['base', 'web', 'base_setup'],
'data': [
'res_users.xml',
'auth_oauth_data.xml',
'auth_oauth_data.yml',
'auth_oauth_view.xml',
'security/ir.model.access.csv'
'security/ir.model.access.csv',
'views/auth_oauth_login.xml',
],
'js': ['static/src/js/auth_oauth.js'],
'css': [
'static/lib/zocial/css/zocial.css',
'static/src/css/auth_oauth.css',
],
'qweb': ['static/src/xml/auth_oauth.xml'],
'installable': True,
'auto_install': False,
}
6 changes: 3 additions & 3 deletions addons/auth_oauth/auth_oauth_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<field name="scope"></field>
<field name="validation_endpoint">https://graph.facebook.com/me/permissions</field>
<field name="data_endpoint"></field>
<field name="css_class">zocial facebook</field>
<field name="css_class">fa fa-facebook-square</field>
<field name="body">Log in with facebook</field>
</record>
<record id="provider_google" model="auth.oauth.provider">
Expand All @@ -26,7 +26,7 @@
<field name="scope">https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile</field>
<field name="validation_endpoint">https://www.googleapis.com/oauth2/v1/tokeninfo</field>
<field name="data_endpoint">https://www.googleapis.com/oauth2/v1/userinfo</field>
<field name="css_class">zocial google</field>
<field name="css_class">fa fa-google-plus-square</field>
<field name="body">Log in with google</field>
</record>
<!--
Expand All @@ -36,7 +36,7 @@
<field name="scope"></field>
<field name="validation_endpoint">https://api.twitter.com/oauth/authorize</field>
<field name="data_endpoint"></field>
<field name="css_class">zocial twitter</field>
<field name="css_class">fa-twitter</field>
<field name="body">Sign in with twitter</field>
</record>
-->
Expand Down
77 changes: 58 additions & 19 deletions addons/auth_oauth/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import openerp
from openerp import SUPERUSER_ID
from openerp import http
from openerp.http import request
from openerp.http import request, LazyResponse
from openerp.addons.web.controllers.main import db_monodb, set_cookie_and_redirect, login_and_redirect
from openerp.modules.registry import RegistryManager
from openerp.tools.translate import _

_logger = logging.getLogger(__name__)

Expand All @@ -34,22 +35,60 @@ def wrapper(self, *a, **kw):
return func(self, *a, **kw)
return wrapper


#----------------------------------------------------------
# Controller
#----------------------------------------------------------
class OAuthController(http.Controller):

@http.route('/auth_oauth/list_providers', type='json', auth='none')
def list_providers(self, dbname):
class OAuthLogin(openerp.addons.web.controllers.main.Home):
def list_providers(self):
try:
registry = RegistryManager.get(dbname)
with registry.cursor() as cr:
providers = registry.get('auth.oauth.provider')
l = providers.read(cr, SUPERUSER_ID, providers.search(cr, SUPERUSER_ID, [('enabled', '=', True)]))
provider_obj = request.registry.get('auth.oauth.provider')
providers = provider_obj.search_read(request.cr, SUPERUSER_ID, [('enabled', '=', True)])
except Exception:
l = []
return l
providers = []
for provider in providers:
return_url = request.httprequest.url_root + 'auth_oauth/signin'
state = self.get_state(provider)
params = dict(
debug=request.debug,
response_type='token',
client_id=provider['client_id'],
redirect_uri=return_url,
scope=provider['scope'],
state=simplejson.dumps(state),
)
provider['auth_link'] = provider['auth_endpoint'] + '?' + werkzeug.url_encode(params)

return providers

def get_state(self, provider):
return dict(
d=request.session.db,
p=provider['id']
)

@http.route()
def web_login(self, *args, **kw):
providers = self.list_providers()

response = super(OAuthLogin, self).web_login(*args, **kw)
if isinstance(response, LazyResponse):
error = request.params.get('oauth_error')
if error == '1':
error = _("Sign up is not allowed on this database.")
elif error == '2':
error = _("Access Denied")
elif error == '3':
error = _("You do not have access to this database or your invitation has expired. Please ask for an invitation and be sure to follow the link in your invitation email.")
else:
error = None

response.params['values']['providers'] = providers
if error:
response.params['values']['error'] = error

return response

class OAuthController(http.Controller):

@http.route('/auth_oauth/signin', type='http', auth='none')
@fragment_to_query_string
Expand All @@ -66,27 +105,27 @@ def signin(self, **kw):
cr.commit()
action = state.get('a')
menu = state.get('m')
url = '/'
url = '/web'
if action:
url = '/#action=%s' % action
url = '/web#action=%s' % action
elif menu:
url = '/#menu_id=%s' % menu
url = '/web#menu_id=%s' % menu
return login_and_redirect(*credentials, redirect_url=url)
except AttributeError:
# auth_signup is not installed
_logger.error("auth_signup not installed on database %s: oauth sign up cancelled." % (dbname,))
url = "/#action=login&oauth_error=1"
url = "/web/login?oauth_error=1"
except openerp.exceptions.AccessDenied:
# oauth credentials not valid, user could be on a temporary session
_logger.info('OAuth2: access denied, redirect to main page in case a valid session exists, without setting cookies')
url = "/#action=login&oauth_error=3"
url = "/web/login?oauth_error=3"
redirect = werkzeug.utils.redirect(url, 303)
redirect.autocorrect_location_header = False
return redirect
except Exception, e:
# signup error
_logger.exception("OAuth2: %s" % str(e))
url = "/#action=login&oauth_error=2"
url = "/web/login?oauth_error=2"

return set_cookie_and_redirect(url)

Expand All @@ -105,7 +144,7 @@ def oea(self, **kw):
try:
model, provider_id = IMD.get_object_reference(cr, SUPERUSER_ID, 'auth_oauth', 'provider_openerp')
except ValueError:
return set_cookie_and_redirect('/?db=%s' % dbname)
return set_cookie_and_redirect('/web?db=%s' % dbname)
assert model == 'auth.oauth.provider'

state = {
Expand Down
4 changes: 2 additions & 2 deletions addons/auth_oauth/res_users.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

import urllib
import werkzeug.urls
import urlparse
import urllib2
import simplejson
Expand All @@ -25,7 +25,7 @@ class res_users(osv.Model):
]

def _auth_oauth_rpc(self, cr, uid, endpoint, access_token, context=None):
params = urllib.urlencode({'access_token': access_token})
params = werkzeug.url_encode({'access_token': access_token})
if urlparse.urlparse(endpoint)[4]:
url = endpoint + '&' + params
else:
Expand Down
2 changes: 1 addition & 1 deletion addons/auth_oauth/res_users.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<xpath expr="//page[@string='Access Rights']" position="after">
<page string="Oauth">
<group>
<field name="oauth_provider"/>
<field name="oauth_provider_id"/>
<field name="oauth_uid"/>
<field name="oauth_access_token"/>
</group>
Expand Down
31 changes: 0 additions & 31 deletions addons/auth_oauth/static/lib/zocial/README.md

This file was deleted.

Binary file not shown.
Loading

0 comments on commit 4b30f1f

Please sign in to comment.