def load_res_partner(ctx): """ Import res.partner from csv """ path = 'install/generated/dj_test/comp1/res.partner.csv' model = ctx.env['res.partner'].with_context(tracking_disable=True) header_exclude = ['commercial_partner_id/id', 'parent_id/id'] load_csv(ctx, model, path, header_exclude=header_exclude) if header_exclude: load_csv(ctx, model, path)
def test_load_csv_file_model_string(tmpdir): csvfile = tmpdir.mkdir("files").join("res.partner.csv") csvfile.write(csv_partner) with anthem.cli.Context(None, anthem.cli.Options(test_mode=True)) as ctx: load_csv(ctx, 'res.partner', csvfile.strpath, delimiter=',') partner1 = ctx.env.ref('__test__.partner1', raise_if_not_found=False) assert partner1 assert partner1.name == 'Partner 1' partner2 = ctx.env.ref('__test__.partner2', raise_if_not_found=False) assert partner2 assert partner2.name == 'Partner 2'
def load_res_users(ctx): """ Import res.users from csv """ path = 'install/generated/dj_test/comp1/res.users.csv' model = ctx.env['res.users'].with_context(no_reset_password=True, tracking_disable=True) load_csv(ctx, model, path)