parameters: (self, field, records)
docstring: Insert missing translations for `field` on `records`.
docstring_summary: Insert missing translations for `field` on `records`.
docstring_tokens: Insert missing translations for field on records .
function: def insert_missing(self, field, records):
          """ Insert missing translations for `field` on `records`. """
          records = records.with_context(lang=None)
          external_ids = records.get_external_id()  # if no xml_id, empty string
          if callable(field.translate):
              # insert missing translations for each term in src
              query = """ INSERT INTO ir_translation (lang, type, name, res_id, src, value, module, state)
                          SELECT l.code, 'model_terms', %(name)s, %(res_id)s, %(src)s, '', %(module)s, 'to_translate'
                          FROM res_lang l
                          WHERE l.active AND NOT EXISTS (
                              SELECT 1 FROM ir_translation
                              WHERE lang=l.code AND type='model' AND name=%(name)s AND res_id=%(res_id)s AND src=%(src)s
                          )
                          ON CONFLICT DO NOTHING;
                      """
              for record in records:
                  module = external_ids[record.id].split('.')[0]
                  src = record[field.name] or None
                  for term in set(field.get_trans_terms(src)):
                      self._cr.execute(query, {
                          'name': "%s,%s" % (field.model_name, field.name),
                          'res_id': record.id,
                          'src': term,
                          'module': module
                      })
          else:
              # insert missing translations for src
              query = """ INSERT INTO ir_translation (lang, type, name, res_id, src, value, module, state)
                          SELECT l.code, 'model', %(name)s, %(res_id)s, %(src)s, '', %(module)s, 'to_translate'
                          FROM res_lang l
                          WHERE l.active AND NOT EXISTS (
                              SELECT 1 FROM ir_translation
                              WHERE lang=l.code AND type='model' AND name=%(name)s AND res_id=%(res_id)s
                          );
  
                          DELETE FROM ir_translation dup
                          WHERE type='model' AND name=%(name)s AND res_id=%(res_id)s
                              AND dup.id NOT IN (SELECT MAX(t.id)
                                         FROM ir_translation t
                                         WHERE t.lang=dup.lang AND type='model' AND name=%(name)s AND res_id=%(res_id)s
                              );
  
                          UPDATE ir_translation SET src=%(src)s
                          WHERE type='model' AND name=%(name)s AND res_id=%(res_id)s;
                      """
              for record in records:
                  module = external_ids[record.id].split('.')[0]
                  self._cr.execute(query, {
                      'name': "%s,%s" % (field.model_name, field.name),
                      'res_id': record.id,
                      'src': record[field.name] or None,
                      'module': module
                  })
          self._modified_model(field.model_name)
function_tokens: def insert_missing ( self , field , records ) : records = records . with_context ( lang = None ) external_ids = records . get_external_id ( ) # if no xml_id, empty string if callable ( field . translate ) : # insert missing translations for each term in src query = """ INSERT INTO ir_translation (lang, type, name, res_id, src, value, module, state)
                          SELECT l.code, 'model_terms', %(name)s, %(res_id)s, %(src)s, '', %(module)s, 'to_translate'
                          FROM res_lang l
                          WHERE l.active AND NOT EXISTS (
                              SELECT 1 FROM ir_translation
                              WHERE lang=l.code AND type='model' AND name=%(name)s AND res_id=%(res_id)s AND src=%(src)s
                          )
                          ON CONFLICT DO NOTHING;
                      """ for record in records : module = external_ids [ record . id ] . split ( '.' ) [ 0 ] src = record [ field . name ] or None for term in set ( field . get_trans_terms ( src ) ) : self . _cr . execute ( query , { 'name' : "%s,%s" % ( field . model_name , field . name ) , 'res_id' : record . id , 'src' : term , 'module' : module } ) else : # insert missing translations for src query = """ INSERT INTO ir_translation (lang, type, name, res_id, src, value, module, state)
                          SELECT l.code, 'model', %(name)s, %(res_id)s, %(src)s, '', %(module)s, 'to_translate'
                          FROM res_lang l
                          WHERE l.active AND NOT EXISTS (
                              SELECT 1 FROM ir_translation
                              WHERE lang=l.code AND type='model' AND name=%(name)s AND res_id=%(res_id)s
                          );
  
                          DELETE FROM ir_translation dup
                          WHERE type='model' AND name=%(name)s AND res_id=%(res_id)s
                              AND dup.id NOT IN (SELECT MAX(t.id)
                                         FROM ir_translation t
                                         WHERE t.lang=dup.lang AND type='model' AND name=%(name)s AND res_id=%(res_id)s
                              );
  
                          UPDATE ir_translation SET src=%(src)s
                          WHERE type='model' AND name=%(name)s AND res_id=%(res_id)s;
                      """ for record in records : module = external_ids [ record . id ] . split ( '.' ) [ 0 ] self . _cr . execute ( query , { 'name' : "%s,%s" % ( field . model_name , field . name ) , 'res_id' : record . id , 'src' : record [ field . name ] or None , 'module' : module } ) self . _modified_model ( field . model_name )