[MERGE] forward port of branch 7.0 up to f410266

This commit is contained in:
Christophe Simonis 2015-08-11 16:35:00 +02:00
commit d5a6380726
5 changed files with 42 additions and 29 deletions

View File

@ -1735,7 +1735,9 @@ class account_invoice_tax(osv.osv):
company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0]
if currency_id and company_currency: if currency_id and company_currency:
amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount, context={'date': date_invoice or fields.date.context_today(self, cr, uid)}, round=False) amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount, context={'date': date_invoice or fields.date.context_today(self, cr, uid)}, round=False)
return {'value': {'tax_amount': amount}} tax_rec = self.browse(cr, uid, ids)
tax_sign = (tax_rec[0].tax_amount / tax_rec[0].amount) if tax_rec and tax_rec[0].amount else 1
return {'value': {'tax_amount': amount * tax_sign}}
_order = 'sequence' _order = 'sequence'
_defaults = { _defaults = {

View File

@ -255,7 +255,7 @@
<field domain="[('partner_id', '=', partner_id)]" name="partner_bank_id" on_change="onchange_partner_bank(partner_bank_id)"/> <field domain="[('partner_id', '=', partner_id)]" name="partner_bank_id" on_change="onchange_partner_bank(partner_bank_id)"/>
<field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'account.group_account_invoice']}"/> <field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'account.group_account_invoice']}"/>
<field name="name" attrs="{'invisible': [('type', '=', 'in_invoice')]}"/> <field name="name" attrs="{'invisible': [('type', '=', 'in_invoice')]}"/>
<field name="payment_term" options="{'no_create': True}"/> <field name="payment_term" options="{'no_create': True}" on_change="onchange_payment_term_date_invoice(payment_term, date_invoice)"/>
</group> </group>
<group> <group>
<field name="move_id" groups="account.group_account_user"/> <field name="move_id" groups="account.group_account_user"/>
@ -387,7 +387,7 @@
<field name="reconciled" invisible="1"/> <field name="reconciled" invisible="1"/>
</group> </group>
<group> <group>
<field name="payment_term" class="oe_inline"/> <field name="payment_term" class="oe_inline" on_change="onchange_payment_term_date_invoice(payment_term, date_invoice)"/>
</group> </group>
<div class="oe_clear"> <div class="oe_clear">
<label for="comment"/> <label for="comment"/>

View File

@ -73,22 +73,18 @@ class res_users(osv.osv):
cr.commit() cr.commit()
return res[0] if res else False return res[0] if res else False
def check(self, db, uid, passwd): def check_credentials(self, cr, uid, password):
try: try:
return super(res_users, self).check(db, uid, passwd) return super(res_users, self).check_credentials(cr, uid, password)
except openerp.exceptions.AccessDenied: except openerp.exceptions.AccessDenied:
if not passwd: cr.execute('''SELECT COUNT(1)
FROM res_users
WHERE id=%s
AND openid_key=%s
AND active=%s''',
(int(uid), password, True))
if not cr.fetchone()[0]:
raise raise
with RegistryManager.get(db).cursor() as cr:
cr.execute('''SELECT COUNT(1)
FROM res_users
WHERE id=%s
AND openid_key=%s
AND active=%s''',
(int(uid), passwd, True))
if not cr.fetchone()[0]:
raise
self._uid_cache.setdefault(db, {})[uid] = passwd

View File

@ -147,7 +147,7 @@ class sale_advance_payment_inv(osv.osv_memory):
'partner_id': sale.partner_invoice_id.id, 'partner_id': sale.partner_invoice_id.id,
'invoice_line': [(0, 0, inv_line_values)], 'invoice_line': [(0, 0, inv_line_values)],
'currency_id': sale.pricelist_id.currency_id.id, 'currency_id': sale.pricelist_id.currency_id.id,
'comment': '', 'comment': sale.note,
'payment_term': sale.payment_term.id, 'payment_term': sale.payment_term.id,
'fiscal_position': sale.fiscal_position.id or sale.partner_id.property_account_position.id 'fiscal_position': sale.fiscal_position.id or sale.partner_id.property_account_position.id
} }

View File

@ -138,7 +138,7 @@ class res_users(osv.osv):
avatar, ... The user model is now dedicated to technical data. avatar, ... The user model is now dedicated to technical data.
""" """
__admin_ids = {} __admin_ids = {}
_uid_cache = {} __uid_cache = {}
_inherits = { _inherits = {
'res.partner': 'partner_id', 'res.partner': 'partner_id',
} }
@ -305,6 +305,24 @@ class res_users(osv.osv):
return result return result
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False):
if uid != SUPERUSER_ID:
groupby_fields = set([groupby] if isinstance(groupby, basestring) else groupby)
if groupby_fields.intersection(USER_PRIVATE_FIELDS):
raise openerp.exceptions.AccessError('Invalid groupby')
return super(res_users, self).read_group(
cr, uid, domain, fields, groupby, offset=offset, limit=limit, context=context, orderby=orderby)
def _search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False, access_rights_uid=None):
if user != SUPERUSER_ID and args:
domain_terms = [term for term in args if isinstance(term, (tuple, list))]
domain_fields = set(left for (left, op, right) in domain_terms)
if domain_fields.intersection(USER_PRIVATE_FIELDS):
raise openerp.exceptions.AccessError('Invalid search criterion')
return super(res_users, self)._search(
cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count,
access_rights_uid=access_rights_uid)
def create(self, cr, uid, vals, context=None): def create(self, cr, uid, vals, context=None):
user_id = super(res_users, self).create(cr, uid, vals, context=context) user_id = super(res_users, self).create(cr, uid, vals, context=context)
user = self.browse(cr, uid, user_id, context=context) user = self.browse(cr, uid, user_id, context=context)
@ -336,10 +354,10 @@ class res_users(osv.osv):
clear = partial(self.pool['ir.rule'].clear_cache, cr) clear = partial(self.pool['ir.rule'].clear_cache, cr)
map(clear, ids) map(clear, ids)
db = cr.dbname db = cr.dbname
if db in self._uid_cache: if db in self.__uid_cache:
for id in ids: for id in ids:
if id in self._uid_cache[db]: if id in self.__uid_cache[db]:
del self._uid_cache[db][id] del self.__uid_cache[db][id]
self.context_get.clear_cache(self) self.context_get.clear_cache(self)
return res return res
@ -347,10 +365,10 @@ class res_users(osv.osv):
if 1 in ids: if 1 in ids:
raise osv.except_osv(_('Can not remove root user!'), _('You can not remove the admin user as it is used internally for resources created by OpenERP (updates, module installation, ...)')) raise osv.except_osv(_('Can not remove root user!'), _('You can not remove the admin user as it is used internally for resources created by OpenERP (updates, module installation, ...)'))
db = cr.dbname db = cr.dbname
if db in self._uid_cache: if db in self.__uid_cache:
for id in ids: for id in ids:
if id in self._uid_cache[db]: if id in self.__uid_cache[db]:
del self._uid_cache[db][id] del self.__uid_cache[db][id]
return super(res_users, self).unlink(cr, uid, ids, context=context) return super(res_users, self).unlink(cr, uid, ids, context=context)
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100): def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
@ -491,15 +509,12 @@ class res_users(osv.osv):
if not passwd: if not passwd:
# empty passwords disallowed for obvious security reasons # empty passwords disallowed for obvious security reasons
raise openerp.exceptions.AccessDenied() raise openerp.exceptions.AccessDenied()
if self._uid_cache.get(db, {}).get(uid) == passwd: if self.__uid_cache.setdefault(db, {}).get(uid) == passwd:
return return
cr = self.pool.db.cursor() cr = self.pool.db.cursor()
try: try:
self.check_credentials(cr, uid, passwd) self.check_credentials(cr, uid, passwd)
if self._uid_cache.has_key(db): self.__uid_cache[db][uid] = passwd
self._uid_cache[db][uid] = passwd
else:
self._uid_cache[db] = {uid:passwd}
finally: finally:
cr.close() cr.close()