[MERGE] forward port of branch saas-6 up to 6a306a03be

This commit is contained in:
Denis Ledoux
2015-10-28 14:01:10 +01:00
14 changed files with 76 additions and 34 deletions
+2 -4
View File
@@ -857,11 +857,9 @@ class google_calendar(osv.AbstractModel):
if actSrc == 'GG':
try:
self.delete_an_event(cr, uid, current_event[0], context=context)
except Exception, e:
error = json.loads(e.read())
error_nr = error.get('error', {}).get('code')
except urllib2.HTTPError, e:
# if already deleted from gmail or never created
if error_nr in (404, 410,):
if e.code in (404, 410,):
pass
else:
raise e
+1 -1
View File
@@ -395,7 +395,7 @@ class PaymentTransaction(osv.Model):
custom_method_name = '%s_compute_fees' % acquirer.provider
if hasattr(Acquirer, custom_method_name):
fees = getattr(Acquirer, custom_method_name)(
cr, uid, acquirer.id, values.get('amount', 0.0), values.get('currency_id'), values.get('country_id'), context=None)
cr, uid, acquirer.id, values.get('amount', 0.0), values.get('currency_id'), values.get('partner_country_id'), context=None)
values['fees'] = float_round(fees, 2)
# custom create
@@ -79,8 +79,7 @@
t-field-options='{"widget": "monetary", "display_currency": "statement.currency_id"}'/>
</td>
<td class="text-right" groups="base.group_multi_currency">
<span t-field="statement.currency"
t-field-options='{"widget": "monetary", "display_currency": "statement.currency"}'/>
<span t-field="statement.currency"/>
</td>
<td class="text-right"><span t-field="statement.state"/></td>
</tr>
+1 -1
View File
@@ -140,8 +140,8 @@ class wizard_user(osv.osv_memory):
wizard_user.user_id.write({'active': True, 'groups_id': [(4, portal.id)]})
# prepare for the signup process
wizard_user.user_id.partner_id.signup_prepare()
self._send_email(cr, uid, wizard_user.id, context)
wizard_user.refresh()
self._send_email(cr, uid, wizard_user.id, context)
else:
# remove the user (if it exists) from the portal group
if wizard_user.user_id and (portal in wizard_user.user_id.groups_id):
+4 -4
View File
@@ -2341,7 +2341,7 @@ class stock_move(osv.osv):
context = context or {}
quant_obj = self.pool.get("stock.quant")
uom_obj = self.pool['product.uom']
to_assign_moves = []
to_assign_moves = set()
main_domain = {}
todo_moves = []
operations = set()
@@ -2349,12 +2349,12 @@ class stock_move(osv.osv):
if move.state not in ('confirmed', 'waiting', 'assigned'):
continue
if move.location_id.usage in ('supplier', 'inventory', 'production'):
to_assign_moves.append(move.id)
to_assign_moves.add(move.id)
#in case the move is returned, we want to try to find quants before forcing the assignment
if not move.origin_returned_move_id:
continue
if move.product_id.type == 'consu':
to_assign_moves.append(move.id)
to_assign_moves.add(move.id)
continue
else:
todo_moves.append(move)
@@ -2419,7 +2419,7 @@ class stock_move(osv.osv):
#force assignation of consumable products and incoming from supplier/inventory/production
# Do not take force_assign as it would create pack operations
if to_assign_moves:
self.write(cr, uid, to_assign_moves, {'state': 'assigned'}, context=context)
self.write(cr, uid, list(to_assign_moves), {'state': 'assigned'}, context=context)
if not no_prepare:
self.check_recompute_pack_op(cr, uid, ids, context=context)
@@ -44,7 +44,7 @@ class stock_change_product_qty(osv.osv_memory):
try:
self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context)
except (AccessError):
pass
location_id = False
res['location_id'] = location_id
return res
+11 -9
View File
@@ -37,16 +37,16 @@ class WebsiteMembership(http.Controller):
partner_obj = request.registry['res.partner']
post_name = post.get('search') or post.get('name', '')
current_country = None
today = time.strftime(DEFAULT_SERVER_DATE_FORMAT)
# base domain for groupby / searches
base_line_domain = [("partner.website_published", "=", True), ('state', 'in', ['free', 'paid'])]
base_line_domain = [
("partner.website_published", "=", True), ('state', '=', 'paid'),
('date_to', '>=', today), ('date_from', '<=', today)
]
if membership_id and membership_id != 'free':
membership_id = int(membership_id)
today = time.strftime(DEFAULT_SERVER_DATE_FORMAT)
base_line_domain += [
('membership_id', '=', membership_id), ('date_to', '>=', today),
('date_from', '<=', today), ('state', '=', 'paid')
]
base_line_domain.append(('membership_id', '=', membership_id))
membership = product_obj.browse(cr, uid, membership_id, context=context)
else:
membership = None
@@ -58,12 +58,14 @@ class WebsiteMembership(http.Controller):
if membership_id != 'free':
membership_line_ids = membership_line_obj.search(cr, SUPERUSER_ID, base_line_domain, context=context)
country_domain = [('member_lines', 'in', membership_line_ids)]
if not membership_id:
country_domain = ['|', country_domain[0], ('membership_state', '=', 'free')]
else:
membership_line_ids = []
country_domain = [('membership_state', '=', 'free')]
if post_name:
country_domain += ['|', ('name', 'ilike', post_name),
('website_description', 'ilike', post_name)]
if post_name:
country_domain += ['|', ('name', 'ilike', post_name),
('website_description', 'ilike', post_name)]
countries = partner_obj.read_group(
cr, SUPERUSER_ID, country_domain + [("website_published", "=", True)], ["id", "country_id"],
groupby="country_id", orderby="country_id", context=request.context)
@@ -36,8 +36,8 @@
</div>
</div>
<h1>Payment Methods</h1>
<h4>Add a new payment method:</h4>
<div class="row">
<h4 t-if="acquirers">Add a new payment method:</h4>
<div t-if="acquirers" class="row">
<div class="col-md-6">
<div t-if="error_message" class="alert alert-danger">
<t t-foreach="error_message" t-as="err"><t t-esc="err"/><br /></t>
+10 -4
View File
@@ -229,6 +229,11 @@ class website(orm.Model):
sale_order_id = request.session.get('sale_order_id') or (partner.last_website_so_id.id if partner.last_website_so_id and partner.last_website_so_id.state == 'draft' else False)
sale_order = None
# Test validity of the sale_order_id
if sale_order_id and sale_order_obj.exists(cr, SUPERUSER_ID, sale_order_id, context=context):
sale_order = sale_order_obj.browse(cr, SUPERUSER_ID, sale_order_id, context=context)
else:
sale_order_id = None
pricelist_id = request.session.get('website_sale_current_pl')
if force_pricelist and self.pool['product.pricelist'].search_count(cr, uid, [('id', '=', force_pricelist)], context=context):
@@ -254,15 +259,12 @@ class website(orm.Model):
sale_order_obj.write(cr, SUPERUSER_ID, [sale_order_id], values, context=context)
request.session['sale_order_id'] = sale_order_id
sale_order = sale_order_obj.browse(cr, SUPERUSER_ID, sale_order_id, context=context)
if request.website.partner_id.id != partner.id:
self.pool['res.partner'].write(cr, SUPERUSER_ID, partner.id, {'last_website_so_id': sale_order_id})
if sale_order_id:
sale_order = sale_order_obj.browse(cr, SUPERUSER_ID, sale_order_id, context=context)
if not sale_order.exists():
request.session['sale_order_id'] = None
return None
# check for change of pricelist with a coupon
pricelist_id = pricelist_id or partner.property_product_pricelist.id
@@ -321,6 +323,10 @@ class website(orm.Model):
if (code and code != sale_order.pricelist_id.code) or sale_order.partner_id.id != partner.id or force_pricelist:
sale_order = sale_order_obj.browse(cr, SUPERUSER_ID, sale_order.id, context=context)
else:
request.session['sale_order_id'] = None
return None
return sale_order
def sale_get_transaction(self, cr, uid, ids, context=None):
@@ -59,7 +59,7 @@
t-field="product.lst_price"
t-field-options='{
"widget": "monetary",
"from_currency": "website.currency_id",
"from_currency": "product.company_id.currency_id",
"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"
}'/>
<span class="oe_price" style="white-space: nowrap;"
@@ -67,7 +67,7 @@
t-field="product.price"
t-field-options='{
"widget": "monetary",
"from_currency": "website.currency_id",
"from_currency": "product.company_id.currency_id",
"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"
}'/>
</td>
@@ -107,7 +107,7 @@
t-field="product.lst_price"
t-field-options='{
"widget": "monetary",
"from_currency": "website.currency_id",
"from_currency": "product.company_id.currency_id",
"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"
}'/><br/>
<span class="oe_price" style="white-space: nowrap;"
+11
View File
@@ -0,0 +1,11 @@
Saudi Arabia, 2015-10-13
I hereby agree to the terms of the Odoo Individual Contributor License
Agreement v1.0.
I declare that I am authorized and able to make this agreement and sign this
declaration.
Signed,
Mohammed Barsi barsintod@gmail.com
@@ -36,6 +36,7 @@
<field name="symbol">R$</field>
<field name="rounding">0.01</field>
<field name="active" eval="False"/>
<field name="position">before</field>
</record>
<record id="CNY" model="res.currency">
@@ -229,6 +230,7 @@
<field name="symbol">$</field>
<field name="rounding">0.01</field>
<field name="active" eval="False"/>
<field name="position">before</field>
</record>
<record id="MYR" model="res.currency">
@@ -275,3 +275,27 @@ class TestGlobalDefaults(FiltersCase):
dict(name='a', user_id=False, is_default=False, domain='[]', context='{}', sort='[]'),
dict(name='b', user_id=False, is_default=True, domain='[]', context=context_value, sort='[]'),
])
from openerp.tests.common import TransactionCase
class TestReadGroup(TransactionCase):
"""Test function read_group with groupby on a many2one field to a model
(in test, "user_id" to "res.users") which is ordered by an inherited not stored field (in
test, "name" inherited from "res.partners").
"""
def setUp(self):
super(TestReadGroup, self).setUp()
self.ir_filters_model = self.env['ir.filters']
self.res_partner_model = self.env['res.partner']
self.res_users_model = self.env['res.users']
def test_read_group_1(self):
self.assertEqual(self.res_users_model._order, "name, login", "Model res.users must be ordered by name, login")
self.assertFalse(self.res_users_model._fields['name'].store, "Field name is not stored in res.users")
filter_a = self.ir_filters_model.create(dict(name="Filter_A", model_id="ir.filters"))
filter_b = self.ir_filters_model.create(dict(name="Filter_B", model_id="ir.filters"))
filter_b.write(dict(user_id=False))
res = self.ir_filters_model.read_group([], ['name', 'user_id'], ['user_id'])
self.assertTrue(any(val['user_id'] == False for val in res), "At least one group must contain val['user_id'] == False.")
+3 -3
View File
@@ -2152,7 +2152,7 @@ class BaseModel(object):
return parent_alias
@api.model
def _inherits_join_calc(self, alias, field, query):
def _inherits_join_calc(self, alias, field, query, implicit=True, outer=False):
"""
Adds missing table select and join clause(s) to ``query`` for reaching
the field coming from an '_inherits' parent table (no duplicates).
@@ -2172,7 +2172,7 @@ class BaseModel(object):
# JOIN parent_model._table AS parent_alias ON alias.parent_field = parent_alias.id
parent_alias, _ = query.add_join(
(alias, parent_model._table, parent_field, 'id', parent_field),
implicit=True,
implicit=implicit, outer=outer,
)
model, alias = parent_model, parent_alias
# handle the case where the field is translated
@@ -4673,7 +4673,7 @@ class BaseModel(object):
parent_obj = self.pool[self._inherit_fields[order_field][3]]
order_column = parent_obj._columns[order_field]
if order_column._classic_read:
inner_clauses = [self._inherits_join_calc(alias, order_field, query)]
inner_clauses = [self._inherits_join_calc(alias, order_field, query, implicit=False, outer=True)]
add_dir = True
elif order_column._type == 'many2one':
key = (parent_obj._name, order_column._obj, order_field)