mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
no msg
This commit is contained in:
committed by
lreficent
parent
8a25028eab
commit
fcab3d846f
@@ -263,12 +263,9 @@ class QcTestTemplate(orm.Model):
|
|||||||
|
|
||||||
def _default_name(self, cr, uid, context=None):
|
def _default_name(self, cr, uid, context=None):
|
||||||
if context and context.get('reference_model', False):
|
if context and context.get('reference_model', False):
|
||||||
templ_id = context.get('reference_id')
|
if 'reference_id' in context:
|
||||||
if not templ_id:
|
|
||||||
templ_id = context.get('active_id')
|
|
||||||
if templ_id:
|
|
||||||
source = self.pool[context['reference_model']].browse(
|
source = self.pool[context['reference_model']].browse(
|
||||||
cr, uid, id, context=context)
|
cr, uid, context.get('active_id'), context=context)
|
||||||
if hasattr(source, 'name'):
|
if hasattr(source, 'name'):
|
||||||
return source.name
|
return source.name
|
||||||
|
|
||||||
@@ -446,11 +443,13 @@ class QcTest(orm.Model):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def copy(self, cr, uid, copy_id, default=None, context=None):
|
def copy(self, cr, uid, copy_id, default=None, context=None):
|
||||||
|
if context is None:
|
||||||
|
context = {}
|
||||||
if default is None:
|
if default is None:
|
||||||
default = {}
|
default = {}
|
||||||
default['name'] = time.strftime('%Y-%m-%d %H:%M:%S')
|
default['name'] = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
return super(QcTest, self).copy(
|
return super(QcTest, self).copy(cr, uid, copy_id, default,
|
||||||
cr, uid, copy_id, default, context=context)
|
context=context)
|
||||||
|
|
||||||
def create(self, cr, uid, datas, context=None):
|
def create(self, cr, uid, datas, context=None):
|
||||||
if context and context.get('reference_model', False):
|
if context and context.get('reference_model', False):
|
||||||
@@ -485,19 +484,18 @@ class QcTest(orm.Model):
|
|||||||
test_obj = self.pool['qc.test']
|
test_obj = self.pool['qc.test']
|
||||||
test_line_obj = self.pool['qc.test.line']
|
test_line_obj = self.pool['qc.test.line']
|
||||||
for test_id in ids:
|
for test_id in ids:
|
||||||
test_obj.write(cr, uid, test_id, {
|
test_obj.write(cr, uid, test_id, {'test_template_id': template_id},
|
||||||
'test_template_id': template_id
|
context)
|
||||||
}, context)
|
|
||||||
test = test_obj.browse(cr, uid, test_id, context=context)
|
test = test_obj.browse(cr, uid, test_id, context=context)
|
||||||
|
|
||||||
if len(test.test_line_ids) > 0:
|
if len(test.test_line_ids) > 0:
|
||||||
test_line_obj.unlink(cr, uid,
|
test_line_obj.unlink(cr, uid,
|
||||||
[x.id for x in test.test_line_ids],
|
[x.id for x in test.test_line_ids],
|
||||||
context=context)
|
context=context)
|
||||||
test_lines = self._prepare_test_lines(
|
test_lines = self._prepare_test_lines(
|
||||||
cr, uid, test, force_fill=force_fill, context=context)
|
cr, uid, test, force_fill=force_fill, context=context)
|
||||||
test_obj.write(cr, uid, test_id, {'test_line_ids': test_lines},
|
if test_lines:
|
||||||
context=context)
|
test_obj.write(cr, uid, id, {'test_line_ids': test_lines},
|
||||||
|
context)
|
||||||
|
|
||||||
def _prepare_test_lines(self, cr, uid, test, force_fill=False,
|
def _prepare_test_lines(self, cr, uid, test, force_fill=False,
|
||||||
context=None):
|
context=None):
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ class QcTestWizard(orm.TransientModel):
|
|||||||
_name = 'qc.test.set.template.wizard'
|
_name = 'qc.test.set.template.wizard'
|
||||||
|
|
||||||
def _default_test_template_id(self, cr, uid, context=None):
|
def _default_test_template_id(self, cr, uid, context=None):
|
||||||
active_id = context.get('active_id', False)
|
test = self.pool['qc.test'].browse(
|
||||||
test = self.pool['qc.test'].browse(cr, uid, active_id, context=context)
|
cr, uid, context.get('active_id', False), context=context)
|
||||||
ids = self.pool['qc.test.template'].search(cr, uid, [('object_id', '=',
|
cond = [('object_id', '=', test.object_id.id)]
|
||||||
test.object_id)],
|
ids = self.pool['qc.test.template'].search(cr, uid, cond,
|
||||||
context=context)
|
context=context)
|
||||||
return ids and ids[0] or False
|
return ids and ids[0] or False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user