Exemplo n.º 1
0
 def shell(self, dbname):
     local_vars = {'openerp': openerp}
     with Environment.manage():
         if dbname:
             registry = openerp.modules.registry.RegistryManager.get(dbname)
             with registry.cursor() as cr:
                 uid = openerp.SUPERUSER_ID
                 ctx = Environment(cr, uid, {})['res.users'].context_get()
                 env = Environment(cr, uid, ctx)
                 local_vars['env'] = env
                 local_vars['self'] = env.user
                 self.console(local_vars)
         else:
             self.console(local_vars)
Exemplo n.º 2
0
    def generate_pdf_thread(self,
                            cr,
                            uid,
                            thread_lock,
                            taxe_ids,
                            context=None):
        """
        @param self: The object pointer.
        @param cr: A database cursor
        @param uid: ID of the user currently logged in
        @param ids: List of IDs selected
        @param context: A standard dictionary
        """
        time.sleep(5)
        with Environment.manage():
            #As this function is in a new thread, i need to open a new cursor, because the old one may be closed
            new_cr = self.pool.cursor()
            new_env = Environment(new_cr, uid, context)

            report = new_env['report']
            for taxe in new_env['extraschool.taxcertificate_item'].browse(
                    taxe_ids):
                report.get_pdf(
                    taxe, 'extraschool.tpl_taxe_certificate_wizard_report')

            thread_lock[1].acquire()
            thread_lock[0] -= 1
            if thread_lock[0] == 0:
                new_env['extraschool.taxcertificate'].browse(
                    thread_lock[2]).pdf_ready = True

            thread_lock[1].release()
            new_cr.commit()
            new_cr.close()
            return {}
Exemplo n.º 3
0
    def read_group(self,
                   cr,
                   uid,
                   domain,
                   fields,
                   groupby,
                   offset=0,
                   limit=None,
                   context=None,
                   orderby=False,
                   lazy=True):
        res = super(stock_history, self).read_group(cr,
                                                    uid,
                                                    domain,
                                                    fields,
                                                    groupby,
                                                    offset=offset,
                                                    limit=limit,
                                                    context=context,
                                                    orderby=orderby,
                                                    lazy=lazy)

        if 'parallel_inventory_value' in fields and 'inventory_value' in fields:
            context['date'] = context.get('history_date')
            for line in res:

                with Environment.manage():  # class function
                    env = Environment(cr, uid, context)

                line[
                    'parallel_inventory_value'] = env.user.company_id.currency_id.compute(
                        line['inventory_value'],
                        env.user.company_id.parallel_currency_id)

        return res
Exemplo n.º 4
0
    def get_formview_action(self, cr, uid, id, context=None):
        """
        @return <ir.actions.act_window>
        """

        record = self.browse(cr, uid, id, context=context)[0]
        if not record.subclass_model:
            return super(Superclass, self).get_formview_action(cr, uid, id, context=context)

        create_instance = False
        # try:
        if not record.subclass_id:
            create_instance = True
        # except:
        #     create_instance = True

        if create_instance:
            env = Environment(cr, uid, context)
            env[record.subclass_model].create_instance(id[0] if isinstance(id, list) else id)

        if self._name == record.subclass_model:
            view = super(Superclass, self).get_formview_action(cr, uid, id, context=context)
        else:
            view = self.pool.get(record.subclass_model).get_formview_action(cr, uid, record.subclass_id,
                                                                            context=context)
        return view
Exemplo n.º 5
0
 def on_change_lines(self):
     with Environment.manage():
         env_thread1 = Environment(self._cr, self._uid, self._context)
         amazon_refund_lines_obj = env_thread1['amazon.refund.order.lines']
         for record in self:
             order = record.order_id
             vals = {}
             new_amazon_retrun_lines = []
             for line in order.ept_order_line:
                 if line.amazon_product_id:
                     info = {
                         'amazon_order_line_id': line.id,
                         'amazon_product_id': line.amazon_product_id.id,
                         'product_id': line.amazon_product_id.product_id.id,
                         'product_qty': line.product_uom_qty,
                         'price_subtotal': line.price_subtotal,
                         'order_line_amount': line.price_unit,
                         'order_line_tax': line.order_line_tax,
                         'item_promotion_adjust': line.promotion_discount,
                         'shipping_charge': line.shipping_charge_ept,
                         'shipping_tax': line.shipping_charge_tax,
                         'gift_wrap_charge': line.gift_wrapper_charge,
                         'gift_wrap_tax': line.gift_wrapper_tax,
                         'message': 'CustomerReturn'
                     }
                     vals.update(info)
                     temp_refund_lines = amazon_refund_lines_obj.new(vals)
                     retvals = amazon_refund_lines_obj._convert_to_write(
                         temp_refund_lines._cache)
                     new_amazon_retrun_lines.append(
                         amazon_refund_lines_obj.create(retvals).id)
                     self.company_id = order.warehouse_id.company_id.id
             self.amazon_refund_line_ids = amazon_refund_lines_obj.browse(
                 new_amazon_retrun_lines)
Exemplo n.º 6
0
    def create_return_picking(self):
        with Environment.manage():
            env_thread1 = Environment(self._cr, self._uid, self._context)
            #stock_move_obj=env_thread1['stock.move']

            for picking in self.order_id.picking_ids:
                if picking.picking_type_code != 'outgoing':
                    continue
                moves = []
                move_qty = {}
                for line in self.amazon_refund_line_ids:
                    if line.amazon_order_line_id.sale_order_line_id:
                        move = env_thread1['stock.move'].search([
                            ('procurement_id.sale_line_id', '=',
                             line.amazon_order_line_id.sale_order_line_id.id),
                            ('product_id', '=', line.product_id.id),
                            ('picking_id', '=', picking.id)
                        ])
                        moves.append(move.id)
                        move_qty.update({move.id: line.qty_canceled})
                    result = env_thread1['stock.return.picking'].with_context({
                        'active_id':
                        picking.id
                    }).default_get(fields=[
                        'product_return_moves', 'move_dest_exists',
                        'location_id'
                    ])

                    move_dest_exists = []
                    product_return_moves = []
                    if result.get('move_dest_exists', []):
                        for exist_line in result.get('move_dest_exists', []):
                            if exist_line.get('move_id') in moves:
                                move_dest_exists.append([0, 0, exist_line])
                    if result.get('product_return_moves', []):
                        for move_line in result.get('product_return_moves',
                                                    []):
                            if len(move_line) == 3:
                                if move_line[2].get('move_id') in moves:
                                    if move_qty.get(
                                            move_line[2].get('move_id'),
                                            0.0) > 0.0:
                                        move_line[2].update({
                                            'quantity':
                                            move_qty.get(
                                                move_line.get('move_id'), 0.0)
                                        })
                                    product_return_moves.append(move_line)
                    record = env_thread1['stock.return.picking'].create({
                        'move_dest_exists':
                        move_dest_exists,
                        'product_return_moves':
                        product_return_moves,
                        'location_id':
                        result.get('location_id')
                    })
                    result = record.with_context({
                        'active_id': picking.id
                    }).create_returns()
        return True
Exemplo n.º 7
0
def connect(dbname='trunk', uid=1, context=None):
    r = RegistryManager.get(dbname)
    cr = r.cursor()
    Environment.reset()
    env = Environment(cr, uid, context or {})
    print('Connected to %s with user %s %s' % (dbname, env.uid, env.user.name))
    return env
Exemplo n.º 8
0
 def fixdb(self, dbname):
     with Environment.manage():
         if config['db_name']:
             db_names = config['db_name'].split(',')
         else:
             db_names = openerp.service.db.list_dbs(True)
         for dbname in db_names:
             _logger.info('Running fix for tabase %s' % dbname)
             registry = openerp.modules.registry.RegistryManager.get(dbname)
             with registry.cursor() as cr:
                 uid = openerp.SUPERUSER_ID
                 ctx = Environment(cr, uid, {})['res.users'].context_get()
                 env = Environment(cr, uid, ctx)
                 _logger.info('Fixing database started')
                 env['db.configuration'].fix_db(uninstall_modules=True)
                 _logger.info('Fixing database finished')
Exemplo n.º 9
0
 def get_data(self):
     data = self.context['data']['form']
     env = Environment(self.cr, self.uid, self.context)
     user = env['res.users']
     recs = user.search([('id', '=', self.context['uid'])])[0]
     data['company'] = recs.company_id.name
     return data
    def get_triggered_tasks(cr, uid, task_id, context=None):
        """
        Get the triggered tasks from the task ID

        :param cr: Odoo cursor
        :param uid: User ID getting the triggered tasks
        :param task_id: ID of the activity checking triggered tasks of
        :param context: Odoo context
        :return: list of triggered task dicts
        """
        env = Environment(cr, uid, {})
        api_model = env.registry('nh.clinical.api')
        activity_model = env.registry('nh.activity')
        triggered_ids = activity_model.search(
            cr, uid, [['creator_id', '=', int(task_id)]])
        triggered_tasks_read = activity_model.read(cr, uid, triggered_ids)
        triggered_tasks = []
        for trig_task in triggered_tasks_read:
            access = api_model.check_activity_access(cr,
                                                     uid,
                                                     trig_task['id'],
                                                     context=context)
            is_not_ob = 'ews' not in trig_task['data_model']
            if access and is_not_ob:
                triggered_tasks.append(trig_task)
        return triggered_tasks
Exemplo n.º 11
0
def execute(conf_attrs, dbname, uid, obj, method, *args, **kwargs):
    import openerp
    from openerp.api import Environment
    from openerp.modules.registry import Registry
    for attr, value in conf_attrs.items():
        openerp.tools.config[attr] = value
    with Environment.manage():
        registry = Registry(dbname)
        cr = registry.cursor()
        context = kwargs.get('context') and kwargs.pop('context') or {}
        env = Environment(cr, uid, context)
        # openerp.api.Environment._local.environments = env
        try:
            getattr(env.registry[obj], method)(cr, uid, *args, **kwargs)
            # Commit only when function finish
            env.cr.commit()
        except Exception as exc:
            env.cr.rollback()
            try:
                raise execute.retry(
                    queue=execute.request.delivery_info['routing_key'],
                    exc=exc,
                    countdown=(execute.request.retries + 1) * 60,
                    max_retries=5)
            except Exception as retry_exc:
                raise retry_exc
        finally:
            env.cr.close()
    return True
    def __init__(self, cr, uid, name, context):
        super(PayslipDetailsReport, self).__init__(cr, uid, name, context)
        self.localcontext.update({
            'get_details_by_rule_category':
            self.get_details_by_rule_category,
        })

        self.env = Environment(cr, uid, context)
Exemplo n.º 13
0
 def init(self, cr):
     env = Environment(cr, SUPERUSER_ID, {})
     TaxDetail = env['account.tax.detail']
     tax_details = TaxDetail.search([('ref_move_id', '=', False)])
     for rec in tax_details:
         rec.ref_move_id = rec.invoice_tax_id.invoice_id.move_id or \
             rec.voucher_tax_id.voucher_id.move_id or \
             rec.move_line_id.move_id
Exemplo n.º 14
0
def restore_canceled_payments_state(cr, registry):
    """
    Odoo depreció el estado cancel en la v9 y lo volvió a agregar en la 11,
    nosotros hicimos un backport pero como la mig lo borra, lo tenemos que
    restaurar
    """
    env = Environment(cr, 1, {})
    # solo buscamos amount != 0.0 porque odoo borra los pagos en 0
    cr.execute(
        """
        SELECT partner_id, name, create_date, create_uid,
            reference, state, amount
        FROM account_voucher_copy
        WHERE state = 'cancel' and amount != 0.0
        """, )
    reads = cr.fetchall()
    for read in reads:
        (partner_id, name, create_date, create_uid, reference, state,
         amount) = read

        # como esta cancelado y no hay asiento que vincule, entonces tratamos
        # tratamos de buscar algo unico para vincular el voucher con el payment

        domain = [
            ('partner_id', '=', partner_id),
            ('create_date', '=', create_date),
            ('create_uid', '=', create_uid),
            ('payment_reference', '=', reference),
            # usamos abs porque pagos negativos se convirtieron a positivo
            ('amount', '=', abs(amount)),
            # Odoo los migra en draft
            ('state', '=', 'draft'),
        ]
        payment = env['account.payment'].search(domain)

        # si nos devuelve mas de uno intentamos agregar condición de name
        # no lo hacemos antes ya que en otros casos no sirve
        if len(payment) > 1 and name:
            domain.append(('name', '=', name))
            payment = env['account.payment'].search(domain)

        if len(payment) != 1:
            # TODO borrar, al final lo revertimos porque en realidad en cheques
            # si es necesario que sea unico para poder mapear
            # al final preferimos dar error de log y no parar upgrade por esto
            # que no es crítico
            # _logger.warning(
            #     'Se encontro mas de un payment o ninguno!!! \n'
            #     '* Payments: %s\n'
            #     '* Domain: %s' % (payment, domain))
            raise ValidationError(
                _('Se encontro mas de un payment o ninguno!!! \n'
                  '* Payments: %s\n'
                  '* Domain: %s' % (payment, domain)))

        _logger.info('Cancelando payment %s' % payment)
        payment.state = 'cancel'
Exemplo n.º 15
0
    def test_01_pos_basic_order(self):
        cr = self.registry.cursor()
        assert cr == self.registry.test_cr
        env = Environment(cr, self.uid, {})

        journal_obj = env['account.journal']
        account_obj = env['account.account']
        main_company = env.ref('base.main_company')
        main_pos_config = env.ref('point_of_sale.pos_config_main')

        account_receivable = account_obj.create({'code': 'X1012',
                                                 'name': 'Account Receivable - Test',
                                                 'user_type_id': env.ref('account.data_account_type_receivable').id,
                                                 'reconcile': True})
        field = self.env['ir.model.fields'].search([('name', '=', 'property_account_receivable_id'),
                                                    ('model', '=', 'res.partner'),
                                                    ('relation', '=', 'account.account')], limit=1)
        env['ir.property'].create({'name': 'property_account_receivable_id',
                                   'company_id': main_company.id,
                                   'fields_id': field.id,
                                   'value': 'account.account,' + str(account_receivable.id)})

        # set the company currency to USD, otherwise it will assume
        # euro's. this will cause issues as the sale journal is in
        # USD, because of this all products would have a different
        # price
        main_company.currency_id = env.ref('base.USD')

        test_sale_journal = journal_obj.create({'name': 'Sale Journal - Test',
                                                'code': 'TSJ',
                                                'type': 'sale',
                                                'company_id': main_company.id})

        main_pos_config.journal_id = test_sale_journal
        main_pos_config.write({'journal_ids': [(0, 0, {'name': 'Cash Journal - Test',
                                                       'code': 'TSC',
                                                       'type': 'cash',
                                                       'company_id': main_company.id,
                                                       'journal_user': True})]})

        # open a session, the /pos/web controller will redirect to it
        main_pos_config.open_session_cb()

        # needed because tests are run before the module is marked as
        # installed. In js web will only load qweb coming from modules
        # that are returned by the backend in module_boot. Without
        # this you end up with js, css but no qweb.
        env['ir.module.module'].search([('name', '=', 'point_of_sale')], limit=1).state = 'installed'
        cr.release()

        self.phantom_js("/pos/web",
                        "odoo.__DEBUG__.services['web.Tour'].run('pos_basic_order', 'test')",
                        "odoo.__DEBUG__.services['web.Tour'].tours.pos_basic_order",
                        login="******")

        for order in env['pos.order'].search([]):
            self.assertEqual(order.state, 'paid', "Validated order has payment of " + str(order.amount_paid) + " and total of " + str(order.amount_total))
Exemplo n.º 16
0
 def create(self, cr, uid, ids, data, context=None):
     self.env = Environment(cr, uid, context)
     report_obj = self.env['ir.actions.report.xml']
     report = report_obj.search([('report_name', '=', self.name[7:])])
     if report.ids:
         self.title = report.name
         if report.report_type == 'xlsx':
             return self.create_xlsx_report(ids, data, report)
     return super(ReportXlsx, self).create(cr, uid, ids, data, context)
Exemplo n.º 17
0
def assign_old_sequences(cr, registry):
    with Environment.manage():
        env = Environment(cr, SUPERUSER_ID, {})

        sequence_model = env['ir.sequence']

        claims = env['crm.claim'].search([], order="id")
        for claim in claims:
            claim.code = sequence_model.next_by_code('crm.claim')
Exemplo n.º 18
0
def uninstall_hook(cr, pool):
    '''
     There is a domain that is not erased when uninstalling so in order to
     avoid problems we reinstall 'event_track_assistant' as the action is
     created in that module.
    '''
    env = Environment(cr, SUPERUSER_ID, {})
    update_module = env['ir.module.module'].search([('name', '=',
                                                     'event_track_assistant')])
    update_module.button_upgrade()
 def sub_thread_create_accounting_entries(self, move_id, cost_line):
     with Environment.manage():
         new_env = Environment(self.pool.cursor(),
                               self.env.uid,
                               self.env.context
                               )
         self.env.cr.commit()
         this = self.with_env(env=new_env).browse(self.ids)
         this._create_accounting_entries(move_id, cost_line)
         this.env.cr.commit()
         this.env.cr.close()
Exemplo n.º 20
0
    def process_search_log(self, cr, uid, context=None):
        env = Environment(cr, uid, context=context or {})
        logs = env['website.search.log'].search([])
        if not logs:
            return

        template = env.ref('website_sale_search_log.search_log_email')
        template = template.with_context(lang=env['res.users'].browse(uid).lang, logs=[l.log for l in logs])
        template.send_mail(logs[0].id, force_send=True, raise_exception=True)

        logs.unlink()
    def auto_workflow_process(self,auto_workflow_process_id=False,ids=[]):            
        with Environment.manage():
            env_thread1 = Environment(self._cr,self._uid,self._context)
            sale_order_obj=env_thread1['sale.order']
            sale_order_line_obj=env_thread1['sale.order.line']
            account_payment_obj=env_thread1['account.payment']
            workflow_process_obj=env_thread1['sale.workflow.process.ept']
            if not auto_workflow_process_id:
                work_flow_process_records=workflow_process_obj.search([])
            else:
                work_flow_process_records=workflow_process_obj.browse(auto_workflow_process_id)

            if not work_flow_process_records:
                return True
            
            for work_flow_process_record in work_flow_process_records:
                if not ids:
                    orders=sale_order_obj.search([('auto_workflow_process_id','=',work_flow_process_record.id),('state','not in',('done','cancel','sale')),('invoice_status','!=','invoiced')])#('invoiced','=',False)
                else:
                    orders=sale_order_obj.search([('auto_workflow_process_id','=',work_flow_process_record.id),('id','in',ids)]) 
                if not orders:
                    continue
                for order in orders:
                    if order.invoice_status and order.invoice_status=='invoiced': 
                        continue
                    if work_flow_process_record.validate_order:
                        order.action_confirm()
                    if work_flow_process_record.invoice_policy=='delivery':
                        continue
                    if not work_flow_process_record.invoice_policy and not sale_order_line_obj.search([('product_id.invoice_policy','!=','delivery'),('order_id','in',order.ids)]):
                        continue    
                    if not order.invoice_ids:
                        if work_flow_process_record.create_invoice:
                            order.action_invoice_create()
                    if work_flow_process_record.validate_invoice:
                        for invoice in order.invoice_ids:                        
                            invoice.action_invoice_open()                                                            
                            if work_flow_process_record.register_payment:
                                if invoice.residual:
                                # Create Invoice and Make Payment                                                                                                
                                    vals={
                                        'journal_id':work_flow_process_record.journal_id.id,
                                        'invoice_ids':[(6,0,[invoice.id])],
                                        'communication':invoice.reference,
                                        'currency_id':invoice.currency_id.id,
                                        'payment_type':'inbound',
                                        'partner_id':invoice.commercial_partner_id.id,
                                        'amount':invoice.residual,
                                        'payment_method_id':work_flow_process_record.journal_id.inbound_payment_method_ids.id,
                                        'partner_type':'customer'
                                        }
                                    new_rec=account_payment_obj.create(vals)
                                    new_rec.post()                                
        return True
Exemplo n.º 22
0
 def get_data(self, obj):
     data = {}
     env = Environment(self.cr, self.uid, self.context)
     user = env['res.users']
     recs = user.search([('id', '=', self.context['uid'])])[0]
     data['company'] = recs.company_id.name
     #material_obj = env['streamline.ame.material.take.off'].browse(self.context['active_id'])
     data['start_date'] = obj.start_date
     data['end_date'] = obj.end_date
     data['project_name'] = obj.project_no.name
     return data
Exemplo n.º 23
0
 def fixdb(self, dbname):
     with Environment.manage():
         if config['db_name']:
             db_names = config['db_name'].split(',')
         else:
             db_names = openerp.service.db.list_dbs(True)
         for dbname in db_names:
             _logger.info('Running fix for tabase %s' % dbname)
             registry = openerp.modules.registry.RegistryManager.get(dbname)
             with registry.cursor() as cr:
                 uid = openerp.SUPERUSER_ID
                 ctx = Environment(cr, uid, {})['res.users'].context_get()
                 env = Environment(cr, uid, ctx)
                 _logger.info('Fixing database started')
                 # no formzamos desinstalación por las dudas de que haya
                 # un error en la clasificación de adhoc modules o en datos
                 # (los script de los modulos deberianser quien se encarguen
                 # de limpiar si corresponde)
                 env['db.configuration'].fix_db(uninstall_modules=False)
                 _logger.info('Fixing database finished')
Exemplo n.º 24
0
def set_user_group_for_double_validation(cr, registry):
    """
    En v9 incorporamos un nuevo grupo para pdoer confirmar pagos, lo marcamos
    por defecto para todos los que vienen de v8 porque si tenían double
    validation no pueden hacer pagos
    """
    env = Environment(cr, 1, {})
    invoice_group = env.ref('account.group_account_invoice')
    confirm_group = env.ref('account_payment_group.account_confirm_payment')
    users = env['res.users'].search([('groups_id', '=', invoice_group.id)])
    users.write({'groups_id': [(4, confirm_group.id, None)]})
def migrate(cr, version):
    if not version:
        return

    env = Environment(cr, SUPERUSER_ID, {})
    obj_bukti_potong_line = env["l10n_id.bukti_potong_pph_line"]
    line_ids = obj_bukti_potong_line.search([("name", "=", "/")])
    for line in line_ids:
        tax_code_name = line.tax_code_id.name
        cr.execute("UPDATE l10n_id_bukti_potong_pph_line "
                   "SET name = '%s' "
                   "WHERE id = %d;" % (tax_code_name, line))
Exemplo n.º 26
0
    def test_tour(self):
        self.phantom_js("/", "odoo.__DEBUG__.services['web.Tour'].run('website_crm_tour', 'test')", "odoo.__DEBUG__.services['web.Tour'].tours.website_crm_tour")

        # need environment using the test cursor as it's not committed
        cr = self.registry.cursor()
        assert cr is self.registry.test_cr
        env = Environment(cr, self.uid, {})
        record = env['crm.lead'].search([('description', '=', '### TOUR DATA ###')])
        assert len(record) == 1
        assert record.contact_name == 'John Smith'
        assert record.email_from == '*****@*****.**'
        assert record.partner_name == 'Odoo S.A.'
    def __init__(self, cr, uid, name, context=None):
        if context is None:
            context = {}
        super(product_report_parser, self).__init__(cr,
                                                    uid,
                                                    name,
                                                    context=context)
        self.env = Environment(cr, uid, context)

        self.localcontext.update({
            'time': time,
        })
Exemplo n.º 28
0
def assign_old_sequences(cr, registry):
    if not new_field_code_added:
        # the field was already existing before the installation of the addon
        return
    with Environment.manage():
        env = Environment(cr, SUPERUSER_ID, {})

        sequence_model = env['ir.sequence']

        claims = env['crm.claim'].search([], order="id")
        for claim in claims:
            claim.code = sequence_model.next_by_code('crm.claim')
Exemplo n.º 29
0
def update_operating_unit_location(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    warehouses = env['stock.warehouse'].search([])
    for warehouse in warehouses:
        operating_unit = warehouse.operating_unit_id
        parent_location = warehouse.view_location_id
        locations = env['stock.location'].search([('id', 'child_of',
                                                   [parent_location.id]),
                                                  ('usage', '=', 'internal')])
        for location in locations:
            if operating_unit:
                location.write({'operating_unit_id': operating_unit.id})
    return True
Exemplo n.º 30
0
def migrate(cr, version):
    if not version:
        return

    env = Environment(cr, SUPERUSER_ID, {})
    obj_order = env['fleet.work.order']
    sequence_obj = env['ir.sequence']
    order_ids = obj_order.search([('name', '=', '/')])
    for order in order_ids:
        name = sequence_obj.next_by_code('fleet.work.order')
        cr.execute('UPDATE fleet_work_order '
                   'SET name = \'%s\' '
                   'WHERE id = %d;' % (name, order))