[MERGE] forward port of branch saas-3 up to 8c150c6
This commit is contained in:
commit
87dd06c941
|
@ -53,7 +53,7 @@ class stock_picking(osv.osv):
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'carrier_id':fields.many2one("delivery.carrier","Carrier"),
|
'carrier_id':fields.many2one("delivery.carrier","Carrier"),
|
||||||
'volume': fields.float('Volume'),
|
'volume': fields.float('Volume', copy=False),
|
||||||
'weight': fields.function(_cal_weight, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_weight',
|
'weight': fields.function(_cal_weight, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_weight',
|
||||||
store={
|
store={
|
||||||
'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['move_lines'], 40),
|
'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['move_lines'], 40),
|
||||||
|
@ -64,8 +64,8 @@ class stock_picking(osv.osv):
|
||||||
'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['move_lines'], 40),
|
'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['move_lines'], 40),
|
||||||
'stock.move': (_get_picking_line, ['picking_id', 'product_id','product_uom_qty','product_uom'], 40),
|
'stock.move': (_get_picking_line, ['picking_id', 'product_id','product_uom_qty','product_uom'], 40),
|
||||||
}),
|
}),
|
||||||
'carrier_tracking_ref': fields.char('Carrier Tracking Ref'),
|
'carrier_tracking_ref': fields.char('Carrier Tracking Ref', copy=False),
|
||||||
'number_of_packages': fields.integer('Number of Packages'),
|
'number_of_packages': fields.integer('Number of Packages', copy=False),
|
||||||
'weight_uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True,readonly="1",help="Unit of measurement for Weight",),
|
'weight_uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True,readonly="1",help="Unit of measurement for Weight",),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1442,18 +1442,34 @@ class mail_thread(osv.AbstractModel):
|
||||||
if follower.email == email_address:
|
if follower.email == email_address:
|
||||||
partner_id = follower.id
|
partner_id = follower.id
|
||||||
# second try: check in partners that are also users
|
# second try: check in partners that are also users
|
||||||
|
# Escape special SQL characters in email_address to avoid invalid matches
|
||||||
|
email_address = (email_address.replace('\\', '\\\\').replace('%', '\\%').replace('_', '\\_'))
|
||||||
|
email_brackets = "<%s>" % email_address
|
||||||
if not partner_id:
|
if not partner_id:
|
||||||
ids = partner_obj.search(cr, SUPERUSER_ID, [
|
# exact, case-insensitive match
|
||||||
('email', 'ilike', email_address),
|
ids = partner_obj.search(cr, SUPERUSER_ID,
|
||||||
('user_ids', '!=', False)
|
[('email', '=ilike', email_address),
|
||||||
], limit=1, context=context)
|
('user_ids', '!=', False)],
|
||||||
|
limit=1, context=context)
|
||||||
|
if not ids:
|
||||||
|
# if no match with addr-spec, attempt substring match within name-addr pair
|
||||||
|
ids = partner_obj.search(cr, SUPERUSER_ID,
|
||||||
|
[('email', 'ilike', email_brackets),
|
||||||
|
('user_ids', '!=', False)],
|
||||||
|
limit=1, context=context)
|
||||||
if ids:
|
if ids:
|
||||||
partner_id = ids[0]
|
partner_id = ids[0]
|
||||||
# third try: check in partners
|
# third try: check in partners
|
||||||
if not partner_id:
|
if not partner_id:
|
||||||
ids = partner_obj.search(cr, SUPERUSER_ID, [
|
# exact, case-insensitive match
|
||||||
('email', 'ilike', email_address)
|
ids = partner_obj.search(cr, SUPERUSER_ID,
|
||||||
], limit=1, context=context)
|
[('email', '=ilike', email_address)],
|
||||||
|
limit=1, context=context)
|
||||||
|
if not ids:
|
||||||
|
# if no match with addr-spec, attempt substring match within name-addr pair
|
||||||
|
ids = partner_obj.search(cr, SUPERUSER_ID,
|
||||||
|
[('email', 'ilike', email_brackets)],
|
||||||
|
limit=1, context=context)
|
||||||
if ids:
|
if ids:
|
||||||
partner_id = ids[0]
|
partner_id = ids[0]
|
||||||
partner_ids.append(partner_id)
|
partner_ids.append(partner_id)
|
||||||
|
@ -1473,13 +1489,15 @@ class mail_thread(osv.AbstractModel):
|
||||||
partner_id = partner_ids[idx]
|
partner_id = partner_ids[idx]
|
||||||
partner_info = {'full_name': email_address, 'partner_id': partner_id}
|
partner_info = {'full_name': email_address, 'partner_id': partner_id}
|
||||||
result.append(partner_info)
|
result.append(partner_info)
|
||||||
|
|
||||||
# link mail with this from mail to the new partner id
|
# link mail with this from mail to the new partner id
|
||||||
if link_mail and partner_info['partner_id']:
|
if link_mail and partner_info['partner_id']:
|
||||||
|
# Escape special SQL characters in email_address to avoid invalid matches
|
||||||
|
email_address = (email_address.replace('\\', '\\\\').replace('%', '\\%').replace('_', '\\_'))
|
||||||
|
email_brackets = "<%s>" % email_address
|
||||||
message_ids = mail_message_obj.search(cr, SUPERUSER_ID, [
|
message_ids = mail_message_obj.search(cr, SUPERUSER_ID, [
|
||||||
'|',
|
'|',
|
||||||
('email_from', '=', email_address),
|
('email_from', '=ilike', email_address),
|
||||||
('email_from', 'ilike', '<%s>' % email_address),
|
('email_from', 'ilike', email_brackets),
|
||||||
('author_id', '=', False)
|
('author_id', '=', False)
|
||||||
], context=context)
|
], context=context)
|
||||||
if message_ids:
|
if message_ids:
|
||||||
|
|
|
@ -68,7 +68,7 @@ MAIL_TEMPLATE_PLAINTEXT = """Return-Path: <whatever-2a840@postmaster.twitter.com
|
||||||
To: {to}
|
To: {to}
|
||||||
Received: by mail1.openerp.com (Postfix, from userid 10002)
|
Received: by mail1.openerp.com (Postfix, from userid 10002)
|
||||||
id 5DF9ABFB2A; Fri, 10 Aug 2012 16:16:39 +0200 (CEST)
|
id 5DF9ABFB2A; Fri, 10 Aug 2012 16:16:39 +0200 (CEST)
|
||||||
From: Sylvie Lelitre <sylvie.lelitre@agrolait.com>
|
From: Sylvie Lelitre <test.sylvie.lelitre@agrolait.com>
|
||||||
Subject: {subject}
|
Subject: {subject}
|
||||||
MIME-Version: 1.0
|
MIME-Version: 1.0
|
||||||
Content-Type: text/plain
|
Content-Type: text/plain
|
||||||
|
@ -525,6 +525,16 @@ class TestMailgateway(TestMail):
|
||||||
self.assertEqual(frog_group.message_ids[0].author_id.id, extra_partner_id,
|
self.assertEqual(frog_group.message_ids[0].author_id.id, extra_partner_id,
|
||||||
'message_process: email_from -> author_id wrong')
|
'message_process: email_from -> author_id wrong')
|
||||||
|
|
||||||
|
# Do: post a new message with a non-existant email that is a substring of a partner email
|
||||||
|
format_and_process(MAIL_TEMPLATE, email_from='Not really Lombrik Lubrik <oul@email.com>',
|
||||||
|
subject='Re: news (2)',
|
||||||
|
msg_id='<zzzbbbaaaa@agrolait.com>',
|
||||||
|
extra='In-Reply-To: <1198923581.41972151344608186760.JavaMail@agrolait.com>\n')
|
||||||
|
frog_groups = self.mail_group.search(cr, uid, [('name', '=', 'Frogs')])
|
||||||
|
frog_group = self.mail_group.browse(cr, uid, frog_groups[0])
|
||||||
|
# Test: author must not be set, otherwise the system is confusing different users
|
||||||
|
self.assertFalse(frog_group.message_ids[0].author_id, 'message_process: email_from -> mismatching author_id')
|
||||||
|
|
||||||
# Do: post a new message, with a known partner -> duplicate emails -> user
|
# Do: post a new message, with a known partner -> duplicate emails -> user
|
||||||
frog_group.message_unsubscribe([extra_partner_id])
|
frog_group.message_unsubscribe([extra_partner_id])
|
||||||
self.res_users.write(cr, uid, self.user_raoul_id, {'email': 'test_raoul@email.com'})
|
self.res_users.write(cr, uid, self.user_raoul_id, {'email': 'test_raoul@email.com'})
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
import time
|
import time
|
||||||
import openerp.addons.decimal_precision as dp
|
import openerp.addons.decimal_precision as dp
|
||||||
from openerp.osv import fields, osv, orm
|
from openerp.osv import fields, osv, orm
|
||||||
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||||
from openerp.tools import float_compare
|
from openerp.tools import float_compare
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp import tools, SUPERUSER_ID
|
from openerp import tools, SUPERUSER_ID
|
||||||
|
@ -217,8 +217,8 @@ class mrp_bom(osv.osv):
|
||||||
else:
|
else:
|
||||||
# neither product nor template, makes no sense to search
|
# neither product nor template, makes no sense to search
|
||||||
return False
|
return False
|
||||||
domain = domain + [ '|', ('date_start', '=', False), ('date_start', '<=', time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)),
|
domain = domain + [ '|', ('date_start', '=', False), ('date_start', '<=', time.strftime(DEFAULT_SERVER_DATE_FORMAT)),
|
||||||
'|', ('date_stop', '=', False), ('date_stop', '>=', time.strftime(DEFAULT_SERVER_DATETIME_FORMAT))]
|
'|', ('date_stop', '=', False), ('date_stop', '>=', time.strftime(DEFAULT_SERVER_DATE_FORMAT))]
|
||||||
# order to prioritize bom with product_id over the one without
|
# order to prioritize bom with product_id over the one without
|
||||||
ids = self.search(cr, uid, domain, order='product_id', context=context)
|
ids = self.search(cr, uid, domain, order='product_id', context=context)
|
||||||
# Search a BoM which has all properties specified, or if you can not find one, you could
|
# Search a BoM which has all properties specified, or if you can not find one, you could
|
||||||
|
@ -277,8 +277,8 @@ class mrp_bom(osv.osv):
|
||||||
})
|
})
|
||||||
|
|
||||||
for bom_line_id in bom.bom_line_ids:
|
for bom_line_id in bom.bom_line_ids:
|
||||||
if bom_line_id.date_start and bom_line_id.date_start > time.strftime(DEFAULT_SERVER_DATETIME_FORMAT) or \
|
if bom_line_id.date_start and bom_line_id.date_start > time.strftime(DEFAULT_SERVER_DATE_FORMAT) or \
|
||||||
bom_line_id.date_stop and bom_line_id.date_stop < time.strftime(DEFAULT_SERVER_DATETIME_FORMAT):
|
bom_line_id.date_stop and bom_line_id.date_stop < time.strftime(DEFAULT_SERVER_DATE_FORMAT):
|
||||||
continue
|
continue
|
||||||
# all bom_line_id variant values must be in the product
|
# all bom_line_id variant values must be in the product
|
||||||
if bom_line_id.attribute_value_ids:
|
if bom_line_id.attribute_value_ids:
|
||||||
|
@ -662,23 +662,10 @@ class mrp_production(osv.osv):
|
||||||
return {'value': result}
|
return {'value': result}
|
||||||
|
|
||||||
|
|
||||||
def _action_compute_lines(self, cr, uid, ids, properties=None, context=None):
|
def _prepare_lines(self, cr, uid, production, properties=None, context=None):
|
||||||
""" Compute product_lines and workcenter_lines from BoM structure
|
# search BoM structure and route
|
||||||
@return: product_lines
|
|
||||||
"""
|
|
||||||
if properties is None:
|
|
||||||
properties = []
|
|
||||||
results = []
|
|
||||||
bom_obj = self.pool.get('mrp.bom')
|
bom_obj = self.pool.get('mrp.bom')
|
||||||
uom_obj = self.pool.get('product.uom')
|
uom_obj = self.pool.get('product.uom')
|
||||||
prod_line_obj = self.pool.get('mrp.production.product.line')
|
|
||||||
workcenter_line_obj = self.pool.get('mrp.production.workcenter.line')
|
|
||||||
for production in self.browse(cr, uid, ids, context=context):
|
|
||||||
#unlink product_lines
|
|
||||||
prod_line_obj.unlink(cr, SUPERUSER_ID, [line.id for line in production.product_lines], context=context)
|
|
||||||
#unlink workcenter_lines
|
|
||||||
workcenter_line_obj.unlink(cr, SUPERUSER_ID, [line.id for line in production.workcenter_lines], context=context)
|
|
||||||
# search BoM structure and route
|
|
||||||
bom_point = production.bom_id
|
bom_point = production.bom_id
|
||||||
bom_id = production.bom_id.id
|
bom_id = production.bom_id.id
|
||||||
if not bom_point:
|
if not bom_point:
|
||||||
|
@ -694,7 +681,27 @@ class mrp_production(osv.osv):
|
||||||
# get components and workcenter_lines from BoM structure
|
# get components and workcenter_lines from BoM structure
|
||||||
factor = uom_obj._compute_qty(cr, uid, production.product_uom.id, production.product_qty, bom_point.product_uom.id)
|
factor = uom_obj._compute_qty(cr, uid, production.product_uom.id, production.product_qty, bom_point.product_uom.id)
|
||||||
# product_lines, workcenter_lines
|
# product_lines, workcenter_lines
|
||||||
results, results2 = bom_obj._bom_explode(cr, uid, bom_point, production.product_id, factor / bom_point.product_qty, properties, routing_id=production.routing_id.id, context=context)
|
return bom_obj._bom_explode(cr, uid, bom_point, production.product_id, factor / bom_point.product_qty, properties, routing_id=production.routing_id.id, context=context)
|
||||||
|
|
||||||
|
|
||||||
|
def _action_compute_lines(self, cr, uid, ids, properties=None, context=None):
|
||||||
|
""" Compute product_lines and workcenter_lines from BoM structure
|
||||||
|
@return: product_lines
|
||||||
|
"""
|
||||||
|
if properties is None:
|
||||||
|
properties = []
|
||||||
|
results = []
|
||||||
|
prod_line_obj = self.pool.get('mrp.production.product.line')
|
||||||
|
workcenter_line_obj = self.pool.get('mrp.production.workcenter.line')
|
||||||
|
for production in self.browse(cr, uid, ids, context=context):
|
||||||
|
#unlink product_lines
|
||||||
|
prod_line_obj.unlink(cr, SUPERUSER_ID, [line.id for line in production.product_lines], context=context)
|
||||||
|
#unlink workcenter_lines
|
||||||
|
workcenter_line_obj.unlink(cr, SUPERUSER_ID, [line.id for line in production.workcenter_lines], context=context)
|
||||||
|
|
||||||
|
res = self._prepare_lines(cr, uid, production, properties=properties, context=context)
|
||||||
|
results = res[0] # product_lines
|
||||||
|
results2 = res[1] # workcenter_lines
|
||||||
|
|
||||||
# reset product_lines in production order
|
# reset product_lines in production order
|
||||||
for line in results:
|
for line in results:
|
||||||
|
|
|
@ -393,7 +393,7 @@ class pos_session(osv.osv):
|
||||||
if not pos_config.journal_id:
|
if not pos_config.journal_id:
|
||||||
jid = jobj.default_get(cr, uid, ['journal_id'], context=context)['journal_id']
|
jid = jobj.default_get(cr, uid, ['journal_id'], context=context)['journal_id']
|
||||||
if jid:
|
if jid:
|
||||||
jobj.write(cr, uid, [pos_config.id], {'journal_id': jid}, context=context)
|
jobj.write(cr, openerp.SUPERUSER_ID, [pos_config.id], {'journal_id': jid}, context=context)
|
||||||
else:
|
else:
|
||||||
raise osv.except_osv( _('error!'),
|
raise osv.except_osv( _('error!'),
|
||||||
_("Unable to open the session. You have to assign a sale journal to your point of sale."))
|
_("Unable to open the session. You have to assign a sale journal to your point of sale."))
|
||||||
|
@ -407,8 +407,8 @@ class pos_session(osv.osv):
|
||||||
if not cashids:
|
if not cashids:
|
||||||
cashids = journal_proxy.search(cr, uid, [('journal_user','=',True)], context=context)
|
cashids = journal_proxy.search(cr, uid, [('journal_user','=',True)], context=context)
|
||||||
|
|
||||||
journal_proxy.write(cr, uid, cashids, {'journal_user': True})
|
journal_proxy.write(cr, openerp.SUPERUSER_ID, cashids, {'journal_user': True})
|
||||||
jobj.write(cr, uid, [pos_config.id], {'journal_ids': [(6,0, cashids)]})
|
jobj.write(cr, openerp.SUPERUSER_ID, [pos_config.id], {'journal_ids': [(6,0, cashids)]})
|
||||||
|
|
||||||
|
|
||||||
pos_config = jobj.browse(cr, uid, config_id, context=context)
|
pos_config = jobj.browse(cr, uid, config_id, context=context)
|
||||||
|
|
|
@ -37,7 +37,7 @@ access_product_template_pos_manager,product.template pos manager,product.model_p
|
||||||
access_account_move_line,account.move.line,account.model_account_move_line,group_pos_user,1,1,1,0
|
access_account_move_line,account.move.line,account.model_account_move_line,group_pos_user,1,1,1,0
|
||||||
access_account_move_line_manager,account.move.line manager,account.model_account_move_line,group_pos_manager,1,1,1,1
|
access_account_move_line_manager,account.move.line manager,account.model_account_move_line,group_pos_manager,1,1,1,1
|
||||||
access_account_move,account.move,account.model_account_move,group_pos_manager,1,0,0,0
|
access_account_move,account.move,account.model_account_move,group_pos_manager,1,0,0,0
|
||||||
access_account_journal,account.journal,account.model_account_journal,group_pos_user,1,1,1,0
|
access_account_journal,account.journal,account.model_account_journal,group_pos_manager,1,1,1,0
|
||||||
access_account_journal_period_user,account.journal.period user,account.model_account_journal_period,group_pos_user,1,1,1,1
|
access_account_journal_period_user,account.journal.period user,account.model_account_journal_period,group_pos_user,1,1,1,1
|
||||||
access_account_journal_period_manager,account.journal.period manager,account.model_account_journal_period,group_pos_manager,1,0,0,0
|
access_account_journal_period_manager,account.journal.period manager,account.model_account_journal_period,group_pos_manager,1,0,0,0
|
||||||
access_account_analytic_line,account.analytic.line,analytic.model_account_analytic_line,group_pos_user,1,1,1,0
|
access_account_analytic_line,account.analytic.line,analytic.model_account_analytic_line,group_pos_user,1,1,1,0
|
||||||
|
@ -55,7 +55,8 @@ access_res_partner_manager,res.partner manager,base.model_res_partner,group_pos_
|
||||||
access_product_category_manager,product.category manager,product.model_product_category,group_pos_manager,1,1,1,1
|
access_product_category_manager,product.category manager,product.model_product_category,group_pos_manager,1,1,1,1
|
||||||
access_product_pricelist_manager,product.pricelist manager,product.model_product_pricelist,group_pos_manager,1,0,0,0
|
access_product_pricelist_manager,product.pricelist manager,product.model_product_pricelist,group_pos_manager,1,0,0,0
|
||||||
access_pos_session_user,pos.session user,model_pos_session,group_pos_user,1,1,1,0
|
access_pos_session_user,pos.session user,model_pos_session,group_pos_user,1,1,1,0
|
||||||
access_pos_config_user,pos.config user,model_pos_config,group_pos_user,1,1,1,0
|
access_pos_config_user,pos.config user,model_pos_config,group_pos_user,1,0,0,0
|
||||||
|
access_pos_config_manager,pos.config user,model_pos_config,group_pos_manager,1,1,1,0
|
||||||
access_ir_sequence_manager,ir.sequence manager,base.model_ir_sequence,group_pos_manager,1,1,1,1
|
access_ir_sequence_manager,ir.sequence manager,base.model_ir_sequence,group_pos_manager,1,1,1,1
|
||||||
access_product_category_pos_manager,pos.category manager,model_pos_category,group_pos_manager,1,1,1,1
|
access_product_category_pos_manager,pos.category manager,model_pos_category,group_pos_manager,1,1,1,1
|
||||||
access_product_category_pos_user,pos.category user,model_pos_category,group_pos_user,1,0,0,0
|
access_product_category_pos_user,pos.category user,model_pos_category,group_pos_user,1,0,0,0
|
||||||
|
|
|
|
@ -300,7 +300,7 @@ class purchase_requisition_line(osv.osv):
|
||||||
_rec_name = 'product_id'
|
_rec_name = 'product_id'
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'product_id': fields.many2one('product.product', 'Product'),
|
'product_id': fields.many2one('product.product', 'Product', domain=[('purchase_ok', '=', True)]),
|
||||||
'product_uom_id': fields.many2one('product.uom', 'Product Unit of Measure'),
|
'product_uom_id': fields.many2one('product.uom', 'Product Unit of Measure'),
|
||||||
'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure')),
|
'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure')),
|
||||||
'requisition_id': fields.many2one('purchase.requisition', 'Call for Bids', ondelete='cascade'),
|
'requisition_id': fields.many2one('purchase.requisition', 'Call for Bids', ondelete='cascade'),
|
||||||
|
|
|
@ -76,7 +76,9 @@ class sale_order(osv.osv):
|
||||||
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
||||||
warning['message'] = message and message + ' ' + result['warning']['message'] or result['warning']['message']
|
warning['message'] = message and message + ' ' + result['warning']['message'] or result['warning']['message']
|
||||||
|
|
||||||
return {'value': result.get('value',{}), 'warning':warning}
|
if warning:
|
||||||
|
result['warning'] = warning
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class purchase_order(osv.osv):
|
class purchase_order(osv.osv):
|
||||||
|
@ -104,7 +106,9 @@ class purchase_order(osv.osv):
|
||||||
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
||||||
warning['message'] = message and message + ' ' + result['warning']['message'] or result['warning']['message']
|
warning['message'] = message and message + ' ' + result['warning']['message'] or result['warning']['message']
|
||||||
|
|
||||||
return {'value': result.get('value',{}), 'warning':warning}
|
if warning:
|
||||||
|
result['warning'] = warning
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,7 +147,9 @@ class account_invoice(osv.osv):
|
||||||
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
||||||
warning['message'] = message and message + ' ' + result['warning']['message'] or result['warning']['message']
|
warning['message'] = message and message + ' ' + result['warning']['message'] or result['warning']['message']
|
||||||
|
|
||||||
return {'value': result.get('value',{}), 'warning':warning}
|
if warning:
|
||||||
|
result['warning'] = warning
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class stock_picking(osv.osv):
|
class stock_picking(osv.osv):
|
||||||
|
@ -171,8 +177,9 @@ class stock_picking(osv.osv):
|
||||||
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
||||||
warning['message'] = message and message + ' ' + result['warning']['message'] or result['warning']['message']
|
warning['message'] = message and message + ' ' + result['warning']['message'] or result['warning']['message']
|
||||||
|
|
||||||
return {'value': result.get('value',{}), 'warning':warning}
|
if warning:
|
||||||
|
result['warning'] = warning
|
||||||
|
return result
|
||||||
|
|
||||||
class product_product(osv.osv):
|
class product_product(osv.osv):
|
||||||
_inherit = 'product.template'
|
_inherit = 'product.template'
|
||||||
|
@ -221,7 +228,9 @@ class sale_order_line(osv.osv):
|
||||||
warning['title'] = title and title +' & '+result['warning']['title'] or result['warning']['title']
|
warning['title'] = title and title +' & '+result['warning']['title'] or result['warning']['title']
|
||||||
warning['message'] = message and message +'\n\n'+result['warning']['message'] or result['warning']['message']
|
warning['message'] = message and message +'\n\n'+result['warning']['message'] or result['warning']['message']
|
||||||
|
|
||||||
return {'value': result.get('value',{}), 'warning':warning}
|
if warning:
|
||||||
|
result['warning'] = warning
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class purchase_order_line(osv.osv):
|
class purchase_order_line(osv.osv):
|
||||||
|
@ -252,7 +261,9 @@ class purchase_order_line(osv.osv):
|
||||||
warning['title'] = title and title +' & '+result['warning']['title'] or result['warning']['title']
|
warning['title'] = title and title +' & '+result['warning']['title'] or result['warning']['title']
|
||||||
warning['message'] = message and message +'\n\n'+result['warning']['message'] or result['warning']['message']
|
warning['message'] = message and message +'\n\n'+result['warning']['message'] or result['warning']['message']
|
||||||
|
|
||||||
return {'value': result.get('value',{}), 'warning':warning}
|
if warning:
|
||||||
|
result['warning'] = warning
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3516,7 +3516,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
||||||
reinit_value: function(val) {
|
reinit_value: function(val) {
|
||||||
this.internal_set_value(val);
|
this.internal_set_value(val);
|
||||||
this.floating = false;
|
this.floating = false;
|
||||||
if (this.is_started)
|
if (this.is_started && !this.no_rerender)
|
||||||
this.render_value();
|
this.render_value();
|
||||||
},
|
},
|
||||||
initialize_field: function() {
|
initialize_field: function() {
|
||||||
|
@ -3767,7 +3767,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
||||||
}
|
}
|
||||||
if (! no_recurse) {
|
if (! no_recurse) {
|
||||||
var dataset = new instance.web.DataSetStatic(this, this.field.relation, self.build_context());
|
var dataset = new instance.web.DataSetStatic(this, this.field.relation, self.build_context());
|
||||||
this.alive(dataset.name_get([self.get("value")])).done(function(data) {
|
var def = this.alive(dataset.name_get([self.get("value")])).done(function(data) {
|
||||||
if (!data[0]) {
|
if (!data[0]) {
|
||||||
self.do_warn(_t("Render"), _t("No value found for the field "+self.field.string+" for value "+self.get("value")));
|
self.do_warn(_t("Render"), _t("No value found for the field "+self.field.string+" for value "+self.get("value")));
|
||||||
return;
|
return;
|
||||||
|
@ -3780,6 +3780,9 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
||||||
self.display_value["" + self.get("value")] = self.display_value_backup["" + self.get("value")];
|
self.display_value["" + self.get("value")] = self.display_value_backup["" + self.get("value")];
|
||||||
self.render_value(true);
|
self.render_value(true);
|
||||||
});
|
});
|
||||||
|
if (this.view && this.view.render_value_defs){
|
||||||
|
this.view.render_value_defs.push(def);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
display_string: function(str) {
|
display_string: function(str) {
|
||||||
|
@ -4263,7 +4266,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
|
||||||
this.dataset.index = 0;
|
this.dataset.index = 0;
|
||||||
}
|
}
|
||||||
this.trigger_on_change();
|
this.trigger_on_change();
|
||||||
if (this.is_started) {
|
if (this.is_started && !this.no_rerender) {
|
||||||
return self.reload_current_view();
|
return self.reload_current_view();
|
||||||
} else {
|
} else {
|
||||||
return $.when();
|
return $.when();
|
||||||
|
@ -4408,12 +4411,19 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var r;
|
var r;
|
||||||
return _.every(this.records.records, function(record){
|
if (_.isEmpty(this.records.records)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
current_values = {};
|
||||||
|
_.each(this.editor.form.fields, function(field){
|
||||||
|
field._inhibit_on_change_flag = true;
|
||||||
|
field.no_rerender = true;
|
||||||
|
current_values[field.name] = field.get('value');
|
||||||
|
});
|
||||||
|
var valid = _.every(this.records.records, function(record){
|
||||||
r = record;
|
r = record;
|
||||||
_.each(self.editor.form.fields, function(field){
|
_.each(self.editor.form.fields, function(field){
|
||||||
field._inhibit_on_change_flag = true;
|
field.set_value(r.attributes[field.name]);
|
||||||
field.internal_set_value(r.attributes[field.name]);
|
|
||||||
field._inhibit_on_change_flag = false;
|
|
||||||
});
|
});
|
||||||
return _.every(self.editor.form.fields, function(field){
|
return _.every(self.editor.form.fields, function(field){
|
||||||
field.process_modifiers();
|
field.process_modifiers();
|
||||||
|
@ -4421,6 +4431,12 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
|
||||||
return field.is_valid();
|
return field.is_valid();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
_.each(this.editor.form.fields, function(field){
|
||||||
|
field.set('value', current_values[field.name]);
|
||||||
|
field._inhibit_on_change_flag = false;
|
||||||
|
field.no_rerender = false;
|
||||||
|
});
|
||||||
|
return valid;
|
||||||
},
|
},
|
||||||
do_add_record: function () {
|
do_add_record: function () {
|
||||||
if (this.editable()) {
|
if (this.editable()) {
|
||||||
|
|
|
@ -231,8 +231,9 @@
|
||||||
this.records.add(record, {
|
this.records.add(record, {
|
||||||
at: this.prepends_on_create() ? 0 : null});
|
at: this.prepends_on_create() ? 0 : null});
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.ensure_saved().then(function(){
|
return this.ensure_saved().then(function(){
|
||||||
|
return $.when.apply(null, self.editor.form.render_value_defs);
|
||||||
|
}).then(function () {
|
||||||
var $recordRow = self.groups.get_row_for(record);
|
var $recordRow = self.groups.get_row_for(record);
|
||||||
var cells = self.get_cells_for($recordRow);
|
var cells = self.get_cells_for($recordRow);
|
||||||
var fields = {};
|
var fields = {};
|
||||||
|
|
|
@ -729,6 +729,10 @@ class groups_view(osv.osv):
|
||||||
# and introduces the reified group fields
|
# and introduces the reified group fields
|
||||||
# we have to try-catch this, because at first init the view does not exist
|
# we have to try-catch this, because at first init the view does not exist
|
||||||
# but we are already creating some basic groups
|
# but we are already creating some basic groups
|
||||||
|
if not context or context.get('install_mode'):
|
||||||
|
# use installation/admin language for translatable names in the view
|
||||||
|
context = dict(context or {})
|
||||||
|
context.update(self.pool['res.users'].context_get(cr, uid))
|
||||||
view = self.pool['ir.model.data'].xmlid_to_object(cr, SUPERUSER_ID, 'base.user_groups_view', context=context)
|
view = self.pool['ir.model.data'].xmlid_to_object(cr, SUPERUSER_ID, 'base.user_groups_view', context=context)
|
||||||
if view and view.exists() and view._name == 'ir.ui.view':
|
if view and view.exists() and view._name == 'ir.ui.view':
|
||||||
xml1, xml2 = [], []
|
xml1, xml2 = [], []
|
||||||
|
|
|
@ -5927,10 +5927,10 @@ def itemgetter_tuple(items):
|
||||||
def convert_pgerror_23502(model, fields, info, e):
|
def convert_pgerror_23502(model, fields, info, e):
|
||||||
m = re.match(r'^null value in column "(?P<field>\w+)" violates '
|
m = re.match(r'^null value in column "(?P<field>\w+)" violates '
|
||||||
r'not-null constraint\n',
|
r'not-null constraint\n',
|
||||||
str(e))
|
tools.ustr(e))
|
||||||
field_name = m and m.group('field')
|
field_name = m and m.group('field')
|
||||||
if not m or field_name not in fields:
|
if not m or field_name not in fields:
|
||||||
return {'message': unicode(e)}
|
return {'message': tools.ustr(e)}
|
||||||
message = _(u"Missing required value for the field '%s'.") % field_name
|
message = _(u"Missing required value for the field '%s'.") % field_name
|
||||||
field = fields.get(field_name)
|
field = fields.get(field_name)
|
||||||
if field:
|
if field:
|
||||||
|
@ -5942,10 +5942,10 @@ def convert_pgerror_23502(model, fields, info, e):
|
||||||
|
|
||||||
def convert_pgerror_23505(model, fields, info, e):
|
def convert_pgerror_23505(model, fields, info, e):
|
||||||
m = re.match(r'^duplicate key (?P<field>\w+) violates unique constraint',
|
m = re.match(r'^duplicate key (?P<field>\w+) violates unique constraint',
|
||||||
str(e))
|
tools.ustr(e))
|
||||||
field_name = m and m.group('field')
|
field_name = m and m.group('field')
|
||||||
if not m or field_name not in fields:
|
if not m or field_name not in fields:
|
||||||
return {'message': unicode(e)}
|
return {'message': tools.ustr(e)}
|
||||||
message = _(u"The value for the field '%s' already exists.") % field_name
|
message = _(u"The value for the field '%s' already exists.") % field_name
|
||||||
field = fields.get(field_name)
|
field = fields.get(field_name)
|
||||||
if field:
|
if field:
|
||||||
|
@ -5958,7 +5958,7 @@ def convert_pgerror_23505(model, fields, info, e):
|
||||||
|
|
||||||
PGERROR_TO_OE = defaultdict(
|
PGERROR_TO_OE = defaultdict(
|
||||||
# shape of mapped converters
|
# shape of mapped converters
|
||||||
lambda: (lambda model, fvg, info, pgerror: {'message': unicode(pgerror)}), {
|
lambda: (lambda model, fvg, info, pgerror: {'message': tools.ustr(pgerror)}), {
|
||||||
# not_null_violation
|
# not_null_violation
|
||||||
'23502': convert_pgerror_23502,
|
'23502': convert_pgerror_23502,
|
||||||
# unique constraint error
|
# unique constraint error
|
||||||
|
|
Loading…
Reference in New Issue