[MERGE] forward port of branch saas-6 up to 7158eaf
This commit is contained in:
@@ -15,7 +15,7 @@ class AdyenController(http.Controller):
|
||||
_return_url = '/payment/adyen/return/'
|
||||
|
||||
@http.route([
|
||||
'/payment/adyen/return/',
|
||||
'/payment/adyen/return',
|
||||
], type='http', auth='none')
|
||||
def adyen_return(self, **post):
|
||||
_logger.info('Beginning Adyen form_feedback with post data %s', pprint.pformat(post)) # debug
|
||||
@@ -26,3 +26,17 @@ class AdyenController(http.Controller):
|
||||
custom = json.loads(post.pop('merchantReturnData', '{}'))
|
||||
return_url = custom.pop('return_url', '/')
|
||||
return werkzeug.utils.redirect(return_url)
|
||||
|
||||
@http.route([
|
||||
'/payment/adyen/notification',
|
||||
], type='http', auth='none', methods=['POST'])
|
||||
def adyen_notification(self, **post):
|
||||
tx_id = post.get('merchantReference') and request.registry['payment.transaction'].search(request.cr, SUPERUSER_ID, [('reference', 'in', [post.get('merchantReference')])], limit=1, context=request.context)
|
||||
if post.get('eventCode') in ['AUTHORISATION'] and tx_id:
|
||||
tx = request.registry['payment.transaction'].browse(request.cr, SUPERUSER_ID, tx_id, context=request.context)
|
||||
states = (post.get('merchantReference'), post.get('success'), tx.state)
|
||||
if (post.get('success') == 'true' and tx.state == 'done') or (post.get('success') == 'false' and tx.state in ['cancel', 'error']):
|
||||
_logger.info('Notification from Adyen for the reference %s: received %s, state is %s', states)
|
||||
else:
|
||||
_logger.warning('Notification from Adyen for the reference %s: received %s but state is %s', states)
|
||||
return '[accepted]'
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
<th>Description</th>
|
||||
<th class="text-right">Quantity</th>
|
||||
<th class="text-right">Unit Price</th>
|
||||
<th t-if="display_discount" class="text-right"><span groups="sale.group_discount_per_so_line">Disc.(%)</span></th>
|
||||
<th t-if="display_discount" class="text-right" groups="sale.group_discount_per_so_line">Disc.(%)</th>
|
||||
<th class="text-right">Taxes</th>
|
||||
<th class="text-right">Price</th>
|
||||
</tr>
|
||||
|
||||
@@ -33,18 +33,16 @@ class view(osv.osv):
|
||||
|
||||
def _view_obj(self, cr, uid, view_id, context=None):
|
||||
if isinstance(view_id, basestring):
|
||||
try:
|
||||
return self.pool['ir.model.data'].xmlid_to_object(
|
||||
cr, uid, view_id, raise_if_not_found=True, context=context
|
||||
)
|
||||
except:
|
||||
# Try to fallback on key instead of xml_id
|
||||
if 'website_id' in context:
|
||||
domain = [('key', '=', view_id), '|', ('website_id', '=', False), ('website_id', '=', context.get('website_id'))]
|
||||
rec_id = self.search(cr, uid, domain, order='website_id', context=context)
|
||||
else:
|
||||
rec_id = self.search(cr, uid, [('key', '=', view_id)], context=context)
|
||||
if rec_id:
|
||||
_logger.info("Could not find view with `xml_id' '%s', fallback on `key'" % (view_id))
|
||||
return self.browse(cr, uid, rec_id, context=context)[0]
|
||||
else:
|
||||
raise
|
||||
if rec_id:
|
||||
return self.browse(cr, uid, rec_id, context=context)[0]
|
||||
else:
|
||||
return self.pool['ir.model.data'].xmlid_to_object(
|
||||
cr, uid, view_id, raise_if_not_found=True, context=context)
|
||||
elif isinstance(view_id, (int, long)):
|
||||
return self.browse(cr, uid, view_id, context=context)
|
||||
|
||||
|
||||
@@ -228,7 +228,7 @@ options.registry.gallery = options.Class.extend({
|
||||
var $container = this.$target.find(".container:first");
|
||||
var editor = new widget.MediaDialog(this.$target.closest('.o_editable'), null, {select_images: true});
|
||||
editor.appendTo(document.body);
|
||||
var index = Math.max(_.map(this.$target.find("img").get(), function (img) { return img.dataset.index | 0; })) + 1;
|
||||
var index = Math.max(0, _.max(_.map(this.$target.find("img").get(), function (img) { return img.dataset.index | 0; })) + 1);
|
||||
editor.on('saved', this, function (attachments) {
|
||||
for (var i = 0 ; i < attachments.length; i++) {
|
||||
var img = $('<img class="img img-responsive mb8 mt8"/>')
|
||||
@@ -335,7 +335,6 @@ options.registry.gallery_img = options.Class.extend({
|
||||
if (type !== "click") return;
|
||||
|
||||
var $parent = this.$target.closest("section");
|
||||
this.buildingBlock.create_overlay($parent);
|
||||
var editor = $parent.data('snippet-editor').styles.gallery;
|
||||
var imgs = $parent.find('img').get();
|
||||
imgs.sort(function (a,b) { return $(a).data('index')-$(b).data('index'); });
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li t-if="submenu.child_id" t-attf-class="dropdown #{
|
||||
(submenu.url and submenu.url != '/' and any([request.httprequest.path == child.url.replace('/page/website.', '/page/') for child in submenu.child_id]) or
|
||||
(submenu.url and submenu.url != '/' and any([request.httprequest.path == child.url.replace('/page/website.', '/page/') for child in submenu.child_id if child.url]) or
|
||||
(submenu.url and request.httprequest.path == submenu.url.replace('/page/website.', '/page/'))) and 'active'
|
||||
}">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
|
||||
@@ -179,6 +179,11 @@ class lang(osv.osv):
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
|
||||
if 'code' in vals:
|
||||
for rec in self.browse(cr, uid, ids, context):
|
||||
if rec.code != vals['code']:
|
||||
raise UserError(_("Language code cannot be modified."))
|
||||
|
||||
if vals.get('active') == False:
|
||||
users = self.pool.get('res.users')
|
||||
if self.search_count(cr, uid, [('id', 'in', ids), ('code', '=', 'en_US')], context=context):
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
access_test_inherit_mother,access_test_inherit_mother,model_test_inherit_mother,,1,1,1,1
|
||||
access_test_inherit_daughter,access_test_inherit_daughter,model_test_inherit_daughter,,1,1,1,1
|
||||
access_test_inherit_property,access_test_inherit_property,model_test_inherit_property,,1,1,1,1
|
||||
|
||||
|
@@ -78,3 +78,35 @@ class res_partner(models.Model):
|
||||
|
||||
# define a one2many field based on the inherited field partner_id
|
||||
daughter_ids = fields.One2many('test.inherit.daughter', 'partner_id')
|
||||
|
||||
|
||||
# Check the overriding of property fields by non-property fields.
|
||||
# Contribution by Adrien Peiffer (ACSONE).
|
||||
class test_inherit_property(models.Model):
|
||||
_name = 'test.inherit.property'
|
||||
|
||||
_columns = {
|
||||
'name': osv.fields.char('Name', required=True),
|
||||
'property_foo': osv.fields.property(string='Foo', type='integer'),
|
||||
'property_bar': osv.fields.property(string='Bar', type='integer'),
|
||||
}
|
||||
|
||||
class test_inherit_property(models.Model):
|
||||
_inherit = 'test.inherit.property'
|
||||
|
||||
@api.multi
|
||||
def _get_foo(self, name, arg):
|
||||
return dict.fromkeys(self.ids, 42)
|
||||
|
||||
_columns = {
|
||||
# override property_foo with an old-api function field
|
||||
'property_foo': osv.fields.function(_get_foo, type='integer', string='Foo'),
|
||||
}
|
||||
|
||||
# override property_bar with a new-api computed field
|
||||
property_bar = fields.Integer(compute='_compute_bar', company_dependent=False)
|
||||
|
||||
@api.multi
|
||||
def _compute_bar(self):
|
||||
for record in self:
|
||||
record.property_bar = 42
|
||||
|
||||
@@ -76,3 +76,20 @@ class test_inherits(common.TransactionCase):
|
||||
# search the partner from the daughter record
|
||||
partners = self.env['res.partner'].search([('daughter_ids', 'in', daughter.ids)])
|
||||
self.assertIn(partner_demo, partners)
|
||||
|
||||
|
||||
class test_override_property(common.TransactionCase):
|
||||
|
||||
def test_override_with_function_field(self):
|
||||
""" test overriding a property field by a function field """
|
||||
record = self.env['test.inherit.property'].create({'name': "Stuff"})
|
||||
# record.property_foo is not a property field
|
||||
self.assertEqual(record.property_foo, 42)
|
||||
self.assertFalse(type(record).property_foo.company_dependent)
|
||||
|
||||
def test_override_with_computed_field(self):
|
||||
""" test overriding a property field by a computed field """
|
||||
record = self.env['test.inherit.property'].create({'name': "Stuff"})
|
||||
# record.property_bar is not a property field
|
||||
self.assertEqual(record.property_bar, 42)
|
||||
self.assertFalse(type(record).property_bar.company_dependent)
|
||||
|
||||
@@ -1430,6 +1430,7 @@ class function(_column):
|
||||
def to_field_args(self):
|
||||
args = super(function, self).to_field_args()
|
||||
args['store'] = bool(self.store)
|
||||
args['company_dependent'] = False
|
||||
if self._type in ('float',):
|
||||
args['digits'] = self._digits_compute or self._digits
|
||||
elif self._type in ('binary',):
|
||||
|
||||
Reference in New Issue
Block a user